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

mysite.com/?hop=hahaha

I would like to remove the hop variable and redirect to

mysite.com/

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)

link|improve this question

45% accept rate
feedback

1 Answer

RewriteEngine On
RewriteCond %{QUERY_STRING}  ^hop=
RewriteRule (.*) $1? [R,L]
link|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
show 8 more comments
feedback

Your Answer

 
or
required, but never shown

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