Forum Moderators: phranque
from php.net on HTTP_REFERER
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
but it should be a little more reliable when you know exactly what page you are getting referred from.
Andreas
Redirect 301 /opera [webmasterworld.com...]
example:
[searchengineworld.com...]
Some domains and their pages (outwith our control) link to our site. I want people clicking on these links to be sent to a special page on our domain explaining the link is unauthorised and not to the pages the link is to.
I want genuine inbound links to be uneffected.
How is this done in htaccess and is this a better method than a script?
RewriteCond %{HTTP_REFERER} ^http://www\.bad1\.com [OR]
RewriteCond %{HTTP_REFERER} ^http://www\.bad2\.com
RewriteRule .* /path/to/bad_page.html [R=301,L] It will redirect people to bad_page when the request header contains a referer field matching [bad[1¦2].com....]
Andreas
SetEnvIfNoCase Referer ^(http://www\.¦http://)domain\.domain\.com ban<Files ~ "^.*$">
order allow,deny
allow from all
deny from env=ban
</Files>
The .htaccess code above will block referrers that begin with http:*//www.domain.domain.com and http:*//domain.domain.com . They will be redirected to a 403 page instead. If you have a custom error 403 page you can list a number of reasons why they might have been banned and include a link to your home page so the visitors can continue to surf on your site.
<added>Remember the broken pipe (¦) needs to be replaced with a solid vertical pipe.</added>
Do you have root access?
If so is mod_rewrite loaded and enabled like so:
LoadModule rewrite_module /usr/lib/apache/1.3/mod_rewrite.so
RewriteEngine on
Of course you would need to adjust the path to the rewrite module.
Key_Master´s solution would work as well. The only draw back is that you are not free to redirect people to any page you want. But it depends only on modules that are compiled and enabled by default.
HTH Andreas
Options +FollowSymLinks
RewriteEngine on
You might want to include the above lines into your .htaccess file.
Make sure that there are no matching RewriteRules with a [L] flag before the rules that should do the redirect.
Options +FollowSymLinks will only work when you have AllowOverride Options privileges which must be granted in the httpd.conf file.
Make sure that Apache actually reads the .htaccess file. This is easily checked by using some unknown directive. When Apache reads this it will return a 500 Internal Server Error.
Have you been using mod_rewrite on this site before and has it been working?
Andreas