Forum Moderators: phranque
I received two alternatives which I show below.
# Block foreign referrers
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://www\.yoursite/ [NC]
RewriteRule .* - [F]
and
SetEnvIf Referer "^http://www\.mysite\.com" allowit
SetEnvIf Referer "^$" allowit
<Limit GET>
Order Deny,Allow
Deny from all
Allow from allowit
</Limit>
Both alternatives deny access with a 403 Forbidden message. Is there a chance that one of them could be re-written to take the visitors to my index page instead of the Forbidden page.
I am a complete novice so any sound advice would be appreciated.
Brutus
Welcome back to WebmasterWorld. The first one could easily be rewritten to redirect them to a different page:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www\.yoursite/ [NC]
RewriteRule .* http://www.yoursite.com/somepage.htm [R,L] [edited by: jdMorgan at 5:22 pm (utc) on Aug. 4, 2005]
[edit reason] Fixed [ code ] formatting. [/edit]
I flushed the cache as you suggested. Now the links will not load at all. The indicator in the "start bar" at the bottom of the page fills from left to right very slowly (it took 3 minutes) when it eventually reached the right hand side of the indicator it just stopped there. The browser refuses to load a page. I tried this on both my machines, same result i'm afraid.
Brutus
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://www\.example\.com/ [NC]
RewriteCond %{REQUEST_URI}!^/index\.html
RewriteRule .* http://www.example.com/index.html [R,L]
I don't know if there's a better way to fix it, but that's one way.
Just to make sure, you are attempting to access the URLs from an outside referer, and they still load? This should work in that, if you type in a URL, it will work. If you click a link from your website, it will work. If you click a link from another site, it will redirect to whateverpageyouchose.html.
I am attempting to access these files from the offending site. I have flushed my cache before each attempt, and the links load quite normally. If I go back to the original files at the beginning of this thread I get the 403 Forbidden page.
Brutus
I have discovered a couple of problems with the code, which, I must hasten to add, works perfectly.
I have a forum on my site, and a members area. I have just discovered that in both cases all login attempts (which require username and password) are redirected to the index page as soon as "Login" is clicked. Can anything be done?
Brutus14