Apache2, HTTP_REFERER usage

Viewed 37

I'd like to allow access to sitea.com, only if the request came from siteb.com, if not, it is redirected to site3.com. Is HTTP_REFERER used for this? Is it limited to links in siteb.com to sitea.com? Should I use something else? Here is a quick example that came to my mind (its rushed and for sure not the best approach):

RewriteCond %{HTTP_REFERER} https://site1\.domain1.com/ [NC]
RewriteRule ^ - [S=3]
RewriteCond %{HTTP_REFERER} https://site2\.domain2.com/ [NC]
RewriteRule ^ - [S=1]
RewriteRule ^(.*)$ https://site1\.domain1.com/ [L,R=301]

Thanks!

0 Answers
Related