querystring with multiple parameters

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 23
Joined: 24 Apr 2012, 13:14

querystring with multiple parameters

18 Jun 2013, 15:58

Hi, I have these two rules working but can't figure out how to have the category rule accept category names with a dash "-" in it.
The second rule works.

This do work (first rule): www.mydomain.com/en/cats
and this also works: www.mydomain.com/en/cats-1/ <-- but I do not want the slash at the end here!
but not: www.mydomain.com/en/cats-1

The second rule
This works: www.mydomain.com/en/cats/my-holy-birma
and also this: www.mydomain.com/en/cats-1/my-holy-birma

The rules are:

RewriteEngine on
RewriteBase /

Code: Select all
# LANGUAGE + CATEGORY
# EX: pages.asp?lng=en&category-name=cats
RewriteCond %{QUERY_STRING} lng=([^&]+)&category-name=([^&]+) [NC]
RewriteRule ^pages\.asp$ /%1/%2? [NC,R=301,L]
RewriteRule ^([^-]+)/([^-]+)$ /pages.asp?lng=$1&category-name=$2 [NC,L]

# LANGUAGE + CATEGORY + PAGE
# EX: pages.asp?lng=en&category-name=cats&pet-name=birma
RewriteCond %{QUERY_STRING} lng=([^&]+)&category-name=([^&]+)&pet-name=([^&]+) [NC]
RewriteRule ^pages\.asp$ /%1/%2/%3? [NC,R=301,L]
RewriteRule ^([^-]+)/([^/]+)/(.*)$ /pages.asp?lng=$1&category-name=$2&pet-name=$3 [NC,L]


How can I correct the rules to make the category names work with a dash in the category name?

Kind Regards
/ Anejo

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: querystring with multiple parameters

18 Jun 2013, 22:08

Hello,

I'm not sure why you use "([^-]+)/", try to replace all of them with "([^/]+)/"

Regards
Andrew

User avatar
Posts: 23
Joined: 24 Apr 2012, 13:14

Re: querystring with multiple parameters

19 Jun 2013, 06:31

Thanks Andrew - this did the trick.

Kind Regards
/ Anejo

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 6 guests