Forum Moderators: phranque
I'm trying to send traffic coming in from one site to a specific page that should stop them.
Currently, I'm using:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?bad_domain\.com [NC]
RewriteCond %{REQUEST_URI}!^/simple.php
RewriteCond %{REQUEST_URI}!^/star_logo_185x175.jpg
RewriteRule .* /simple.php?sid=noway [F,L]
But users get:
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
What am I missing here?
the .php and .jpg files DO exist.
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?bad_domain\.com [NC]
RewriteCond %{REQUEST_URI} !^/simple.php
RewriteCond %{REQUEST_URI} !^/star_logo_185x175.jpg
RewriteRule .* /simple.php?sid=noway [F,L]
What your code is doing is the following: If the visitor is from bad_domain.com and the visitor is not requesting simple.php and not requesting star_logo_185x175.jpg, display the page for a Forbidden document.
I'm guessing that what you want is: If the visitor is from bad_domain.com and the visitor requests simple.php, redirect the visitor permanently to simple.php?sid=noway.
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?bad_domain\.com [NC]
RewriteCond %{REQUEST_URI} /simple.php
RewriteRule .* http://www.mydomain.com/simple.php?sid=noway [R=301,L]
Is that more like what you want to do?
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www\.)?bad_domain\.com [NC]
RewriteCond %{QUERY_STRING} !^sid=noway$
RewriteRule !^(simple\.php¦star\_logo\_185x175\.jpg)$ /simple.php?sid=noway [L]
Posting on this forum modifies the "¦" character. You must replace it with a solid vertical pipe character from your keyboard before using the code.
Jim