Link to home
Start Free TrialLog in
Avatar of sjaguar13
sjaguar13

asked on

No Query Strings in Mod_Rewrite (Opposite of QSA)?

I have:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} f=4
RewriteRule ^theforum/viewforum.php http://www.ceetus.com/forum/promotion-b4.0/ [R=301,L]

It takes this URL:
http://www.ceetus.com/theforum/viewforum.php?f=4&sid=08bc702c566aa6fa5a35b3b3efac9aa0

and makes it:

http://www.ceetus.com/forum/promotion-b4.0/?f=4&sid=08bc702c566aa6fa5a35b3b3efac9aa0

I don't want the ?f=4&sid=08bc702c566aa6fa5a35b3b3efac9aa0 stuff on there. How do I get rid of it?
Avatar of glcummins
glcummins
Flag of United States of America image

Just remove this line:

RewriteCond %{QUERY_STRING} f=4

So your rewrite section becomes:


RewriteEngine On
RewriteBase /
RewriteRule ^theforum/viewforum.php http://www.ceetus.com/forum/promotion-b4.0/ [R=301,L]
Avatar of sjaguar13
sjaguar13

ASKER

Doesn't work. It still adds the ?f=4..... stuff. Plus, I will also need to add other things, like f=5, once I get the stupid file working.
Avatar of Arty K
Try to change this:
RewriteRule ^theforum/viewforum.php http://www.ceetus.com/forum/promotion-b4.0/ [R=301,L]
to this:
RewriteRule ^theforum/viewforum.php(.*)$ http://www.ceetus.com/forum/promotion-b4.0/ [R=301,L]
That doesn't work either. No matter what the rule is, the query string is still appended to the end.

I have a rule for:
http://www.ceetus.com/index2b.html

Where it would go to:
http://www.ceetus.com/

You can add whatever you want for the query, and it redirects to http://www.ceetus.com/?whatever.
ASKER CERTIFIED SOLUTION
Avatar of Arty K
Arty K
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are not sure that it works, read a note in apache documentation page (at the bottom):
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule

Note: Query String
...  When you want to erase an existing query string, end the substitution string with just a question mark. ...