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=08bc702c566aa6fa5 a35b3b3efa c9aa0 stuff on there. How do I get rid of it?
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=08bc702c566aa6fa5
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.
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]
RewriteRule ^theforum/viewforum.php http://www.ceetus.com/forum/promotion-b4.0/ [R=301,L]
to this:
RewriteRule ^theforum/viewforum.php(.*
ASKER
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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. ...
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. ...
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]