matching request url with querystring in map file

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 33
Joined: 18 Jul 2012, 07:50

matching request url with querystring in map file

06 May 2014, 13:25

I have a map file which contains entries like

Code: Select all
details-125.htm?detail=true&id=310 product-delux.html


I want that I should be able to match the url with with or without querystring in map file.

my rules look like

Code: Select all
RewriteCond %{HTTP:Host} ^(?:www\.)?example.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} (?!admin)
RewriteCond ${map:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.*?\.(?:html|htm)) ${map:${lower:$1}} [NC,L,NS,QSA,R=301]

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

Re: matching request url with querystring in map file

06 May 2014, 16:25

Hello,

You'll have to use 2 different rules. But you can still use the same mapfile. Look:

Code: Select all
RewriteCond %{HTTP:Host} ^(?:www\.)?example.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} (?!admin)
RewriteCond ${map:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.*?\.(?:html|htm)) ${map:${lower:$1}} [NC,L,NS,QSA,R=301]

RewriteCond %{HTTP:Host} ^(?:www\.)?example.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} (?!admin)
RewriteCond %{QUERY_STRING} (.*)
RewriteCond ${map:$1\?%1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.*?\.(?:html|htm)) ${map:${lower:$1\?%1}} [NC,L,NS,QSA,R=301]


Also, I'd think that REQUEST_FILENAME check can be omitted, since you do the mapfile check anyway.

Regards

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 11 guests