Solved

No Query Strings in Mod_Rewrite (Opposite of QSA)?

Posted on 2007-03-27
6
1,704 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
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:glcummins
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:sjaguar13
Comment Utility
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
Comment Utility
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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now