Forum Moderators: phranque
Sorry could you give me a example still very new to this
And have Jim make a gelding out of me ;)
This is how I located the Webmaster World forum some eight years ago.
[google.com...]
Just go through the SERPS, until you find examples/tutitorials which inlcude SetEnvIf, however in all honesty?
The previous link I provided will get you there faster.
[webmasterworld.com...]
<Files *>
order allow,deny
deny from xx.xx.xx.xx
SetEnvIfNoCase Referer ^www\.domain\.com banned
allow from all
deny from env=banned
</Files>
edited.
Please note; you have the referrer beginning with "www.".
In the event the referrer begins with "http://www."
Your line will have no effect.
SetEnvIf Referer ^http://www\.domain\.com banned
SetEnvIf Request_URI ^path-to-custom-403-page\.html$ allowed
SetEnvIf Request_URI ^robots\.txt$ allowed
#
Order Deny,Allow
#
Deny from 12.34.56.78
Deny from 34.56.0.0/255.255.0.0
Deny from 56.78.12.0/24
Deny from 78.12
Deny from hackers.com
Deny from env=banned
#
Allow from env=allowed
The fifth Deny line denies based on remote hostname, and will only work on a server that has reverse-DNS lookups enabled (many don't).
The final two lines address your question. Deny line six denies your unwelcome referrer by use of the "banned" server variable set by the SetEnvIf directive above, and the final line allows *all* accesses to your custom 403 error page and your robots.txt file, overriding the previous "Denies" in order to save you a whole lot of trouble...
Jim
<Files *>
SetEnvIf Referer ^http://www\.domaintoban\.com banned
SetEnvIf Referer ^http://domaintoban\.com banned
SetEnvIf Request_URI ^error\.php$ allowed
SetEnvIf Request_URI ^robots\.txt$ allowed
order deny,allow
deny from www.domaintoban.com
deny from domaintoban.com
But this is allowing the link from there forum to our site to still work
Ie link is
[ourdomain.com...]
Be sure to completely flush your browser cache between tests from different referrers; Otherwise your browser will cache the images and pages, and show them to you without making a request to your server. If no request is made to your server, then your server-side code can have no effect.
See the prior note about reverse-DNS not being available on many servers. These two lines won't work on many or most shared-hosting servers:
Deny from www.domaintoban.com
Deny from domaintoban.com
You can also replace these two lines:
SetEnvIf Referer ^http://www\.domaintoban\.com banned
SetEnvIf Referer ^http://domaintoban\.com banned
SetEnvIf Referer ^http://(www\.)?domaintoban\.com banned
For best portability between hosts and servers, observe the *exact* form of each directive, including spacing and capitalization.
Jim
RewriteCond %{HTTP_REFERER} theirdomain\.com/
RewriteRule ^$ [yourdomain...] [R=301,L]
This is causing 404 on the site.
Lets say the site is www.example.co.uk that has the link to our site
Now I want to redirect any user who clicks on that page to another site ie www.redirect.co.uk
Issue is spammers are adding adverts to the site and there is a link on a forum is generator mass spammers on the site
With each instance, you have presented a reason a reason and/or question which is obvious to the three folks providing that solutions, that you have not completed your homework, whilst implementing the solution.
1) you need to modify these to your own requirements.
2) Read up on more htaccess/Apache useage
3) retain another to make these adjustments for you.
In this implentation, there are four questions that need answering:
[webmasterworld.com...]
1) Have you turned on rewrite
2) Have you renamed "theirdomain" and "yourdommain" to the correct names?
3) Have you renamed "adpage" to the correct page with extension?
4) Have you reviewed your error logs?