Mapfile without QueryString

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 12
Joined: 21 Feb 2013, 22:15

Mapfile without QueryString

16 Jan 2014, 13:39

Hi

i'm using a map file to redirect some old url's to new ones.

I have it more or less working, apart from one issue.

Here is my httd.conf

Code: Select all
RewriteMap mapfilet txt:d:\ISAPI_Rewrite3\tele.txt [NC]
RewriteCond %{HTTP:HOST} .*domain.co.uk
RewriteCond ${mapfilet:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://shop.domain.co.uk/${mapfilet:$1} [NC,R=301,L]


Map file:

Code: Select all
abc/def/ghi/?WT.ac=956  shop.asp/menswear-clothing


If the incoming url is matched it is appending the querystring.... so i get this

shop.domain.co.uk/shop.asp/menswear-clothing?WT.ac=956

How can I stop querystring being appended?

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Mapfile without QueryString

17 Jan 2014, 08:25

"How can I stop querystring being appended?"
- you need to put the question mark at the end of substitution string:

RewriteRule (.*) http://shop.domain.co.uk/${mapfilet:$1}? [NC,R=301,L]

User avatar
Posts: 12
Joined: 21 Feb 2013, 22:15

Re: Mapfile without QueryString

20 Jan 2014, 08:22

Brilliant many thanks for that.

This works great for this

Code: Select all
abc/def/ghi/?WT.ac=956  shop.asp/menswear-clothing


However if I have a map file with just:

Code: Select all
?abc=search shop.asp


Then when I try the url
Code: Select all
www.domain.com?abc=search
then the querystring is still attached and it looks like the mapfile isn't being matched?

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Mapfile without QueryString

21 Jan 2014, 07:47

Hello,

Please try to use the following rules:

RewriteMap mapfilet txt:d:\ISAPI_Rewrite3\tele.txt [NC]
RewriteCond %{HTTP:HOST} .*domain.co.uk
RewriteCond ${mapfilet:($1\?%{QUERY_STRING})|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://shop.domain.co.uk/${mapfilet:($1\?%{QUERY_STRING})}? [NC,R=301,L]

User avatar
Posts: 12
Joined: 21 Feb 2013, 22:15

Re: Mapfile without QueryString

21 Jan 2014, 11:04

Many thanks

That works as long as i use both:

Code: Select all
RewriteMap mapfilet txt:d:\ISAPI_Rewrite3\tele.txt [NC]
RewriteCond %{HTTP:HOST} .*domain.co.uk
RewriteCond ${mapfilet:$1|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://shop.domain.co.uk/${mapfilet:$1}? [NC,R=301,L]

RewriteMap mapfilet txt:d:\ISAPI_Rewrite3\tele.txt [NC]
RewriteCond %{HTTP:HOST} .*domain.co.uk
RewriteCond ${mapfilet:($1\?%{QUERY_STRING})|NOT_FOUND} !NOT_FOUND
RewriteRule (.*) http://shop.domain.co.uk/${mapfilet:($1\?%{QUERY_STRING})}? [NC,R=301,L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 0 guests