Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 01-08-2009, 04:39 AM   #1
Advanced Warrior
War Room Member
 
activetrader's Avatar
 
Join Date: Nov 2008
Posts: 693
Thanks: 30
Thanked 107 Times in 78 Posts
Default Htaccess Question

Does anyone know how to write htaccess to deny everyone and allow only certain referrer? I've tried many things and nothing works

Me
activetrader is offline   Reply With Quote
Old 01-08-2009, 08:28 AM   #2
Warrior Nerd
 
KathyK's Avatar
 
Join Date: Nov 2008
Location: SW Florida
Posts: 227
Thanks: 41
Thanked 50 Times in 48 Posts
Default Re: Htaccess Question

Code:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://(www.)?your_domain.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?gooddomain.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://gooddomain.com/ [NC]
RewriteRule ^.*$ http://yourdomain.com/notallowed.html [R=301,L]
Your rewrite base is wherever the .htaccess file is...
I think you'll need to include your own domain or it may not work.

Untested, but I think it will work. Keep in mind that some people/programs block referer by default (I think Norton does) so you might also need a blank referer. It SHOULD redirect anything not equal to those referrers.

Method 2
Have the index be your 'everyone else' page
Code:
RewriteBase /
RewriteCond %{HTTP_REFERER} ^http://(www.)?your_domain.com/ [NC]
RewriteCond %{HTTP_REFERER} ^http://(www.)?gooddomain.com/ [NC]
RewriteRule ^.*$ http://yourdomain.com/yourprivatesalespage.html [R=301,L]
And this one should redirect anything that IS equal to those referrers.

Cheers,
Kathy
KathyK is offline   Reply With Quote
Old 01-08-2009, 10:23 PM   #3
Advanced Warrior
War Room Member
 
activetrader's Avatar
 
Join Date: Nov 2008
Posts: 693
Thanks: 30
Thanked 107 Times in 78 Posts
Default Re: Htaccess Question

Quote:
Originally Posted by KathyK View Post
Code:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://(www.)?your_domain.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?gooddomain.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://gooddomain.com/ [NC]
RewriteRule ^.*$ http://yourdomain.com/notallowed.html [R=301,L]
Your rewrite base is wherever the .htaccess file is...
I think you'll need to include your own domain or it may not work.

Untested, but I think it will work. Keep in mind that some people/programs block referer by default (I think Norton does) so you might also need a blank referer. It SHOULD redirect anything not equal to those referrers.

Method 2
Have the index be your 'everyone else' page
Code:
RewriteBase /
RewriteCond %{HTTP_REFERER} ^http://(www.)?your_domain.com/ [NC]
RewriteCond %{HTTP_REFERER} ^http://(www.)?gooddomain.com/ [NC]
RewriteRule ^.*$ http://yourdomain.com/yourprivatesalespage.html [R=301,L]
And this one should redirect anything that IS equal to those referrers.

Thank you so much. I really like the second idea. The first version looks familiar like I've tried it before, but the second one is an excellent idea. I haven't thought of it before. My IT guy writes some complicated PHP code for me whereas the download page is a temp file authomatically generated after receiving payment confirmation and only works for one IP address and only for two hours, but it was too complicated for me to understand plus I always had to contact him for support.

With htaccess I can set up my thank you page myself. Thanks again!

Me
activetrader is offline   Reply With Quote
Old 01-09-2009, 02:04 AM   #4
Active Warrior
War Room Member
 
Join Date: Dec 2004
Location: , , .
Posts: 41
Thanks: 4
Thanked 6 Times in 4 Posts
Default Re: Htaccess Question

Yeah I've always used that first example. Got it from a google search awhile back.
ch3712 is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
apache, htaccess, question

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 09:42 AM.