Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

mysite.com/subdir/?hop=hahaha or mysite.com/subdir?hop=hahaha

becomes mysite.com/subdir

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

1 Answer 1

RewriteEngine On
RewriteCond %{QUERY_STRING}  ^hop=
RewriteRule (.*) $1? [R,L]
share|improve this answer
Thanks just tried it but it redirects from http://mysite.com/?hop=hahaha to http://mysite.com/home/mysite/public_html 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.