Forum Moderators: phranque

Message Too Old, No Replies

variables go away

rewrite URL so variables are gone

         

smallcompany

4:00 am on Jan 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How do you rewrite your URL so everything after question mark is gone, including the question mark itself?
This should be applicable to both URLs ending with i.e. ".html" and home page or folders ending with "/".
Page names are letters, numbers, and hyphens (multiple).

I thought about something like this:

RewriteRule ^(.*)\.html?(.*) $1.html

Not sure about root and folders ending by "/".

...or I'm thinking everything wrong and should play with %{QUERY_STRING} ? I believe I read somewhere that anything after ? is not really treated as URI but query string - true?

Thanks

jdMorgan

4:22 am on Jan 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



True, and you can read that in many recent threads -- at least one from today.

You need to check the URL with RewriteRule, and the appended query string with a RewriteCond. Then put a "?" at the end of the substitution URL to remove the existing query string on the 301-redirect URL.

Jim

smallcompany

5:08 am on Jan 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Jim.

I'll do the homework. ;)