Mapfile to redirect to remote URL

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Mapfile to redirect to remote URL

18 May 2015, 10:55

Hi,

I frequently use the following code with a mapfile in order to rewrite URLs within a site. However I need to use the same method but to result in a remote URL.

RewriteMap mapfile txt:mapfile.txt

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
Rewriterule ^product\.aspx$ /${mapfile:%1}? [NC,R=301,L]

Here is what I need it to do:

http://myfirstsite.com/product.aspx?productid=12345

to redirect to

http://mysecondsite.com/someotherpage

with the mapfile reading:

productid=12345 someotherpage

Thanks!

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

Re: Mapfile to redirect to remote URL

18 May 2015, 14:56

Hello Johnny,

Please try adding the domain name to the resulting URL like this:

RewriteMap mapfile txt:mapfile.txt

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
Rewriterule ^product\.aspx$ http\://mysecondsite.com/${mapfile:%1}? [NC,R=301,L]

User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Re: Mapfile to redirect to remote URL

18 May 2015, 15:55

That did the trick!

Thank you very much!

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 23 guests