Rewrite Rule with Querystring parameter in URL

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 21 Jan 2015, 15:50

Rewrite Rule with Querystring parameter in URL

21 Jan 2015, 17:50

Hello,

I would like to do Redirect (301) from this URL:

http://localhost/shop/cart-sale?cid=25MSNVEN

To this URL:

http://localhost/tech/cart.htm?cid=25MSNVEN

The code I am using:

RewriteCond %{QUERY_STRING} ^cid=(.*)$ [NC]
RewriteRule ^/shop/cart-sale$ /tech/cart.htm$1 [R=301,NC,L]

But I keep getting to http://localhost/shop/cart-sale?cid=25MSNVEN

Anybody knows how can I modify my rule so the redirect work correctly?

Thanks in advance.

Best Regards.

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

Re: Rewrite Rule with Querystring parameter in URL

22 Jan 2015, 13:42

Please try to use the following rule instead:

RewriteCond %{QUERY_STRING} ^cid=.*& [NC]
RewriteRule ^/shop/cart-sale$ /tech/cart.htm [R=301,NC,L]

User avatar
Posts: 3
Joined: 21 Jan 2015, 15:50

Re: Rewrite Rule with Querystring parameter in URL

22 Jan 2015, 14:25

Hi Anton,

Would you explain to me how the cid parameter will be added to the redirect : /tech/cart.htm
?

Thank you very much.

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

Re: Rewrite Rule with Querystring parameter in URL

22 Jan 2015, 15:02

By default the query string from requested URL is appended to rewritten URL if no other query string is manually added to it.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 5 guests