Page 1 of 1

.htaccess require specific referrer?

Posted: Fri Aug 21, 2009 3:35 pm
by xtk
how would i achieve this?

for example to access x.domain.com or its ip address you must be referred by domain.com or its ip address only, otherwise access denied or custom page

i know a method of using php in the file but i would like it to be global

regards

Re: .htaccess require specific referrer?

Posted: Sat Aug 22, 2009 6:44 am
by redmonkey
I'm guessing since you mention.htaccess files you are using Apache? Apache makes available a number of pre-defined variables for use with mod_rewrite one of which is HTTP_REFERER, you could place some rewrite rules within your .htaccess file to redirect all unwanted referrers to a 401, 403, 404 or some such similar page.

Although, refferer headers can be easily spoofed so it not 100% fail safe.