Forum Moderators: phranque

Message Too Old, No Replies

isapi rewrite

remove default.asp

         

golfinhu

3:19 pm on Feb 3, 2011 (gmt 0)

10+ Year Member



Guys, need a little help!

I have a site written in asp and here I am doing it with the friendly urls isapirewrite

i need to redirect:
mysite.com/default.asp?my-category

to:
mysite.com/my-category/


i did this regular expression:
RewriteRule (/default.asp\?)(.+) $2/ [NC,R=301,L]


but this return:
mysite.com/my-category/?my-category


and tried this too:
RewriteRule /default.asp\? / [NC,R=301,L]


but this return:
mysite.com/?my-category


the "?" is maintained

for me the regular expression is correct


but why the the "?" is maintained?


anyone help me please? thanks a lot!

jdMorgan

8:20 pm on Feb 7, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The "?" delimits the URL-path from the query string, but is part of neither.

It is therefore visible neither to the RewriteRule pattern, nor to a RewriteCond examining %{QUERY_STRING}.

The solution for this on Apache (though no guarantee for ISAPI Rewrite) is:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /default\.asp\?([^\ ]*)\ HTTP/
RewriteRule ^default\.asp$ http://www.exmple.com/%1? [R=301,L]

The question mark in the RewriteRule substitution is NOT a literal, and will not appear in the requested redirected URL. It is an operator which clears the current query string.

Jim

golfinhu

4:02 pm on Feb 8, 2011 (gmt 0)

10+ Year Member



i undestend!

get it!

I'll try it and post the result here later!


thankyou so much!