Click here to Skip to main content
14,875,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,
I got an htaccess question, hopefully you could help me out:

When I have a querystring parameters in URL, I have to make a redirection to the same page without these parameters.


must redirect to:

What is the code for Htaccess file for:
1. Redirect to the same page while cleaning URL from all parameters
2. Doing this only if parameter "print" exist in URL


I hope, the file name is ".htaccess", not "htaccess"? Just checking...

1 solution


RewriteEngine On
RewriteCond %{QUERY_STRING} ^*print=*$ [NC]
RewriteRule ^(.*)$ %{REQUEST_URI}?

I haven't tried it myself, but that should work. If not, check out the documentation here:[^]
vit01982 15-Aug-12 17:40pm
Thank you, but before I try this one, I want to make sure that single url rule is working properly. Please show me htaccess on this example:

must redirect (301) to the same URL with no Query string:

TRK3 15-Aug-12 17:47pm
I'm not here to do your work for you.

I don't have a server set up to try this out on and, as easy as it is to install a stack these days, I am not going to go to all that trouble to test something for you.

Especially, since (assuming you have access to a test server) you could have tested it yourself in about the same amount of time it took you to write the reply. (And if you don't have a test server, then you better set one up before you start making ANY changes on your production server.)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900