Forum Moderators: phranque
First I would like to thank you guys for this great website, I can't say how many times you helped me in the past!
I finally registered today so I could ask a question:
I know the question mark is not part of the query string, but I would like to know if it could be possible to suppress it using mod_rewrite like in this exemple:
http://www.example.com/?search=need+for+speed
to
http://www.example.com/search=need+for+speed
Any input on the subject is greatly appreciated, or maybe some suggestion about what I could do if this is impossible.
Thanks
z0mbie
If you are posting this url from a form, I think you will only be able to redirect to that location and then rewrite it. Im pretty sure the form requires a?
The way i see it is that you have to do two sets of rules to accomplish what you want
1. Redirect from http://www.example.com/?search=need+for+speed to http://www.example.com/search/need+for+speed/ (I changed this becuase i think its better)
2. Rewrite to your internal script to catch the "search" variable from the URL
Here is how I would do it:
#Redirect from form to page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?search=(.*)\ HTTP/ [NC]
RewriteRule ^$ http://www.example.com/search/%1/? [R=301,L]
#Redirect underlying url
RewriteRule ^/?search/([a-zA-Z0-9_\+]+)/?$?search=$1 [NC]
There might be a few bits wrong here and there, but it should get you on the right track.
After this, you will need to rewrite the links in your menus on pages etc. to reflect the new /search/need+for+speed/ logic
Z
[edited by: Zacharias at 4:33 pm (utc) on Aug. 15, 2007]