Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to redirect users to a url without a specific variable. For example

I would like to remove the hop variable and redirect to

This for subdirectories as well for example or


I have this so far but it only works for root domains, not subdirs

RewriteCond %{QUERY_STRING}  ^hop=
RewriteRule .* /? [R,L]

(For reference clickbank adds the hop variables to landing pages)

share|improve this question
RewriteEngine On
RewriteCond %{QUERY_STRING}  ^hop=
RewriteRule (.*) $1? [R,L]
share|improve this answer
Thanks just tried it but it redirects from to It outputs the linux path :) – giorgio79 Nov 15 '11 at 8:56
Where did you put this code? – quanta Nov 15 '11 at 9:09
I am using Drupal, so in Drupal's htaccess after # Various rewrite rules. <IfModule mod_rewrite.c> RewriteEngine on – giorgio79 Nov 15 '11 at 9:21
Can you add it to a Virtual Host section? – quanta Nov 15 '11 at 9:24
I am on a shared host, so no access to that. – giorgio79 Nov 15 '11 at 10:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.