Solved

No Query Strings in Mod_Rewrite (Opposite of QSA)?

Posted on 2007-03-27
6
1,725 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
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 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…

726 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