Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


No Query Strings in Mod_Rewrite (Opposite of QSA)?

Posted on 2007-03-27
Medium Priority
Last Modified: 2013-12-13
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:

and makes it:


I don't want the ?f=4&sid=08bc702c566aa6fa5a35b3b3efac9aa0 stuff on there. How do I get rid of it?
Question by:sjaguar13
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 24

Expert Comment

ID: 18803271
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]

Author Comment

ID: 18803643
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.
LVL 27

Expert Comment

ID: 18804383
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]
Flash Sale! Good things come in big bundles

Save over 50% on our fully managed dedicated server bundle for Labor Day. Plus FREE Guardian Backups, FREE Advanced DDoS Protection and FREE Plesk Onyx Web Pro Edition.


Author Comment

ID: 18804446
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:

Where it would go to:

You can add whatever you want for the query, and it redirects to http://www.ceetus.com/?whatever.
LVL 27

Accepted Solution

Nopius earned 200 total points
ID: 18804550
Try to add '?' at the end of the substitution field:

RewriteRule ^theforum/viewforum.php(.*)$ http://www.ceetus.com/forum/promotion-b4.0/? [R=301,L]
LVL 27

Expert Comment

ID: 18804691
If you are not sure that it works, read a note in apache documentation page (at the bottom):

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

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don’t want your company's site to fail on the web, you’d do well to observe these best web design practices and make sure you implement them when applicable.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question