Solved

No Query Strings in Mod_Rewrite (Opposite of QSA)?

Posted on 2007-03-27
6
1,737 Views
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:
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?
0
Comment
Question by:sjaguar13
[X]
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
6 Comments
 
LVL 24

Expert Comment

by:glcummins
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]
0
 

Author Comment

by:sjaguar13
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.
0
 
LVL 27

Expert Comment

by:Nopius
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]
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

Author Comment

by:sjaguar13
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:
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.
0
 
LVL 27

Accepted Solution

by:
Nopius earned 50 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]
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18804691
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. ...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
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.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 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