Need a little help with .htaccess

wealthy199

BANNED
Joined
Sep 24, 2007
Messages
543
Reaction score
1,254
I realise that you can choose to only allow people coming from certain sites to enter your site through the .htaccess but do not know the correct way to write this.

For example, I only want people coming from http://www.x.com to be able to enter my site at http://www.y.com. I don't want anyone else to be able to view it.

Can someone help me?
 
Here's another. The block hit-bots does the opposite of what you are wanting, but might give ideas. hxxp://www.htaccesstools.com/

Chris
 
Thanks essential and smallstorm. I managed to find my answer at the forum on htaccesstools.com. :)

I'll post the code here if it works.
 
Here's a bit of anti-hotlink code I adapted for you, haven't tested it so don't know if it'll work, I don't see why it shouldn't though:

SetEnvIfNoCase Referer "^(.*)([./]+)x.com(.*)" local_ref=1
SetEnvIfNoCase Referer "^(.*)([./]+)y.com(.*)" local_ref=1

<FilesMatch ".(html|htm|php)">
Order Allow,Deny
Allow from env=local_ref
</FilesMatch>

Just replace x.com and y.com with your domains and save it as .htaccess, then upload to y.com. People should only be able to access html/php files on y.com if the referrer contains y.com or x.com. You'll have to update the FilesMatch bit to specify any other file extensions you're using on y.com (like .asp etc).
 
dear small strom thanks a lot for htaccesstools link . awesome . happy sharing
 
Back
Top