Only allow specific referrers with .htaccess

Apr032007 2:30AM — John

Say you have a secret directory full of stuff you don’t want anyone to see and you want to allow certain domains to have access to it directly. All you would need to do is create (or add this to) a .htaccess file in the root of the directory you want to protect.

You would do it thusly:
Add this to a blank or your existing .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?first-domain-to-allow.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?second-domain-to-allow.com/.*$ [NC]
RewriteRule ^(.*)$ http://www.google.com/ [R,L]

Also, if you want people who copy and paste/type in the link to have access, all you would need to do is add this line just after RewriteEngine on so your .htaccess file would look like this…
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?first-domain-to-allow.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?second-domain-to-allow.com/.*$ [NC]
RewriteRule ^(.*)$ http://www.google.com/ [R,L]

Advertising
TragicallyNull is looking for guest authors. Click here for details.

Recent Comments

coolyo

worked for me thanks lol, nice n easy

DDR for my fingers?

This sounds awesome. I just got my iphone last month. I’m a huge DDR geek and the idea of playing it on my iphone is nuts.

ddrlifechange.com
Chrismcl

i cant get it to work… when i type http://jailbreak.toc2rta.com on my i touch it shows a white screen with a small blue question mark on the top left...

retards lamers

Yolanda if you have problems with this you should not be messing with technology and trying to modify your electronics. its REALLY not for everyone.

joe d

okay its not that confusing but whenever i try to follow the other instructions to upgrade to 1.1.2 using oktoprep the ipod goes into the restore mode, and displays...

Tim

This isn’t a fix. Restarting Steam shows the same error.

jean

would it work on version 1.1.2? reply PLs thnks

theaztec

hey, my ipod doesn’t crash, what do i hve to do?

luciano

when i open the page in the safari, it doesn’t open the page, appears de question sign only

Advertising
Close
E-mail It