neubert
neubert

Reputation: 16792

redirecting with mod_rewrite based on http referer

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https?://www.google.com [NC]
RewriteRule .* http://www.google.com/ [L,R]

What I'm trying to do with this .htaccess file is, for test purposes, to redirect all http requests coming from google.com (be it http or https) to google.com. But it doesn't seem to be working.

Any ideas?

Upvotes: 0

Views: 551

Answers (1)

Prix
Prix

Reputation: 19528

You had a ! before the ^ which means to negate, so it was looking for a %{HTTP_REFERER} that did not start with https://www.google.com or http://www.google.com

When from what you have mentioned you wanted to the opposite:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^https?://www.google.com [NC]
RewriteRule ^ http://www.google.com/ [L,R]

Upvotes: 1

Related Questions