homepage Welcome to WebmasterWorld Guest from 54.234.60.133
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess to block access from one referrer
.htaccess to block access from one referrer
58sniper




msg:1510353
 11:32 pm on Sep 6, 2003 (gmt 0)

Greetings!

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.

 

closed




msg:1510354
 12:08 am on Sep 7, 2003 (gmt 0)

Your code:


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?

jdMorgan




msg:1510355
 12:28 am on Sep 7, 2003 (gmt 0)

I think the point is to ALLOW the bad guy to see simple.php and the star_logo:

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]

Looks like the problem may have been the [F,L] flag. [L] is redundant when used with [F], and [F] redirects to the 403 error handler. Just use [L] to do a "silent" redirect to the noway page.

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

58sniper




msg:1510356
 3:29 am on Sep 7, 2003 (gmt 0)

Ah. Ok. That makes sense. I couldn't figure out why I kept getting the 403 error. As soon as I pulled out the 'F', everything worked fine.

Much appreciated for both the knowledge, and the fix.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved