Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

is it possible to suppress question mark from query string?

2:16 pm on Aug 15, 2007 (gmt 0)

New User

5+ Year Member

joined:Aug 15, 2007
votes: 0

Hey guys,

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:


Any input on the subject is greatly appreciated, or maybe some suggestion about what I could do if this is impossible.


4:28 pm on Aug 15, 2007 (gmt 0)

New User

10+ Year Member

joined:Dec 5, 2005
votes: 0

Here is an alternative

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


[edited by: Zacharias at 4:33 pm (utc) on Aug. 15, 2007]