remove underscore fom URL

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

remove underscore fom URL

20 Nov 2014, 14:24

Hello,

I need a rule that will do the following.

this URL:

http://mysite.com/product.aspx?product_id=123

to be rewritten as:

http://mysite.com/product.aspx?productid=123

Thank You!

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

Re: remove underscore fom URL

21 Nov 2014, 05:47

Hello,

Please try the following rule:

RewriteBase /
RewriteCond %{QUERY_STRING} ^product_id=(\d+)$ [NC]
RewriteRule ^product\.aspx$ /product.aspx/productid=%1 [NC,L]

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

Re: remove underscore fom URL

21 Nov 2014, 17:22

Hi Anton,

I think it just needs some modifications but you are on the right track. Here is what the webserver is seeing when browsing to :

http://mysite.com/product.aspx?product_id=123

It comes through as

http://mysite.com/product.aspx/productid=123 product_id=123

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

Re: remove underscore fom URL

24 Nov 2014, 07:04

Hello,

Please try to fix the rules like this:

RewriteBase /
RewriteCond %{QUERY_STRING} ^product_id=(\d+)$ [NC]
RewriteRule ^product\.aspx$ /product.aspx?productid=%1 [NC,L,QSA]

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

Re: remove underscore fom URL

24 Nov 2014, 12:03

I think it is really close now, here is what the webserver is seeing:

/product.aspx productid=123&product_id=123

It looks like it is appending the &product_id=123 is there a way to fix this?

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

Re: remove underscore fom URL

25 Nov 2014, 08:48

Hello,

Here's the config that should work as expected:

RewriteBase /
RewriteCond %{QUERY_STRING} ^product_id=(\d+)$ [NC]
RewriteRule ^product\.aspx$ /product.aspx?productid=%1 [NC,L]

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

Re: remove underscore fom URL

25 Nov 2014, 14:09

Thanks Anton,

You are a genius. The only thing that I had to change was adding R=301 so

RewriteRule ^product\.aspx$ /product.aspx?productid=%1 [NC,L,R=301]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 18 guests