TotalChoice Hosting Family Forums: .htaccess - Allow Only By Referer - TotalChoice Hosting Family Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

.htaccess - Allow Only By Referer

#1 User is offline   modaven Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 04-November 03

Posted 31 October 2006 - 02:28 PM

Good afternoon-

I have browsed the forums as well as the web looking for an answer to this question. Hope someone out there can help.

I need to create a .htaccess file that will only allow the files in the folder to be seen if the "referer" is from a particular site (or possibly two sites). I have found a lot of solutions out there for people who want to block specific sites, but I can't seem to figure out how to only allow specific sites. I have done some trial and error based on some of the things I have found, but with no luck.

Any ideas?

Thanks in advance!

David

#2 User is offline   TCH-Andy Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Staff
  • Posts: 4,729
  • Joined: 14-January 03

Posted 31 October 2006 - 02:50 PM

Hi David,

Welcome to the forums :)

I haven't tested it, but try;
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.your_domain_name\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.OKdomain1\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.OKdomain2\.com/ [NC]
RewriteRule ^.*$ http://www.your_domain_name.com/not_allowed_here.htm [R=301,L]


or I'd try something along those lines anyway - with the not_allowed_here.htm being a page I redirected all those I don't want to.
Andy Beckett

#3 User is offline   TCH-Thomas Icon

  • Volunteer Moderator
  • PipPipPipPip
  • Group: Moderators
  • Posts: 15,147
  • Joined: 01-May 03

Posted 31 October 2006 - 02:54 PM

Welcome to the forum, David. :)
Thomas Jikrantz
Forum Moderator
TotalChoice Hosting, L.L.C.

Any links or suggestions for third party software/sites should be used at your own risk. My opinions and recommendations are not necessary those of TCH and TCH is not responsible.

As a Forum Moderator I can assist in answering many of your hosting related questions. However, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.

Web Hosting by Total Choice Web Hosting - 24/7 Help Desk

#4 User is offline   modaven Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 04-November 03

Posted 31 October 2006 - 03:06 PM

Thanks, Andy! I'll give that a try this evening after I take the little one out for some trick-or-treating. That way I'll be good an hopped up on sugar when I try it out! :D

#5 User is offline   TCH-Bruce Icon

  • Lead Forum Moderator
  • PipPipPipPip
  • Group: Admins
  • Posts: 21,059
  • Joined: 11-August 03

Posted 31 October 2006 - 03:10 PM

Welcome to the forums David :)
Bruce Richards
Lead Forum Moderator
TotalChoice Hosting, L.L.C.
Webhosting by Total Choice Web Hosting - General Support Forum

I am the Lead Forum Moderator. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related issues. Should you need assistance in these areas, please contact our Help Desk or our many other options. Another good place to find answers is with our help pages, tutorials and movie tutorials.

#6 User is offline   TCH-Don Icon

  • Volunteer Moderator
  • PipPipPipPip
  • Group: Moderators
  • Posts: 11,679
  • Joined: 30-November 02

Posted 31 October 2006 - 03:37 PM

Welcome to the forums and the family David :)
Don Rosenquist
Forum Moderator
TotalChoice Hosting, L.L.C.
Web Hosting by Total Choice Web Hosting - For Your Family - Web Hosting Family!

Any links or suggestions for third party software/sites should be used at your own risk.
My opinions and recommendations are not necessarily those of TCH and TCH is not responsible.

I am a Forum Moderator and a volunteer. While I can assist in answering most of your hosting related questions, I am unable to answer questions about specifics relating to your account such as billing and server related questions. Should you need assistance in these areas, please contact our Help Desk.


treasure your pets

The Turtle says "A little knowledge is a dangerous thing,
so keep learning!"

#7 User is offline   carbonize Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Members
  • Posts: 779
  • Joined: 19-March 05

Posted 31 October 2006 - 04:49 PM

Just remember that not everyone sends a refer. Some firewalls actively block the refer.
Carbonize
Lazarus Guestbook
A SPADE IS A SPADE - I'm here to help people not to win friends or gain popularity.

#8 User is offline   modaven Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 04-November 03

Posted 09 November 2006 - 03:12 PM

View PostTCH-Andy, on Oct 31 2006, 02:50 PM, said:

Hi David,

Welcome to the forums :)

I haven't tested it, but try;
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.your_domain_name\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.OKdomain1\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.OKdomain2\.com/ [NC]
RewriteRule ^.*$ http://www.your_domain_name.com/not_allowed_here.htm [R=301,L]


or I'd try something along those lines anyway - with the not_allowed_here.htm being a page I redirected all those I don't want to.


So I have been trying different variables of the above for a couple days not with no luck. I can get the page to redirect to the "not_allowed_here", but everything goes there, even the request from the referer I want. Here's what I am using, but is not working...

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://www\.yahoo\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www\.google\.com/ [NC]
RewriteRule ^.*$ http://www.totalchoicehosting.com [R=301,L]


The site I am trying to get to is www.vzbmarketcenter.com. Based on what I have above, I would think that anything coming from yahoo.com, www.yahoo.com, google.com or www.google.com would be able to get through, but anything else would go to www.totalchoicehosting.com. I also tried getting rid of the "\"'s, but got the same results.

Sorry, I am not up on the syntax of this, which is probably my problem.

Any thoughts?

Thanks again!!!

David

#9 User is offline   TCH-Andy Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Staff
  • Posts: 4,729
  • Joined: 14-January 03

Posted 09 November 2006 - 04:38 PM

Hi David,

You would need to include your own domain name in the list (otherwise you won't be able to link from one page to another ....) I also suspect you will also need to include a blank (or no refferer) since if you type it in your browser it does not have any refferer.
Andy Beckett

#10 User is offline   modaven Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 04-November 03

Posted 10 November 2006 - 02:50 PM

Andy-

Thanks again! It was the fact that I was missing my own URL that was keeping it from working. I left the referer = "blank" out because I don't want people to be able to type in the URL, they have to come from the site on the list.

Thanks again!!!

David

#11 User is offline   TCH-JimE Icon

  • Volunteer Moderator
  • PipPipPipPip
  • Group: Members
  • Posts: 2,747
  • Joined: 27-November 02

Posted 13 November 2006 - 10:43 AM

Hi David,

One problem you will have is that some versions of norton no longer give a referrer as a header, and hence you will not be able to block them, joys of the internet!

JimE
J

#12 User is offline   carbonize Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Members
  • Posts: 779
  • Joined: 19-March 05

Posted 13 November 2006 - 10:55 AM

It's not only Norton that can block refers.
Carbonize
Lazarus Guestbook
A SPADE IS A SPADE - I'm here to help people not to win friends or gain popularity.

#13 User is offline   modaven Icon

  • New To The Neighborhood
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 04-November 03

Posted 13 November 2006 - 02:03 PM

View Postcarbonize, on Nov 13 2006, 10:55 AM, said:

It's not only Norton that can block refers.


Yeah, it is my customer that is requiring that we limit the site to only be accessible by people coming from their site, and this is the only way I know of doing that. So seems that it is what it is.

Thanks again, all!

David

#14 User is offline   carbonize Icon

  • Immediate Family
  • PipPipPipPip
  • Group: Members
  • Posts: 779
  • Joined: 19-March 05

Posted 13 November 2006 - 04:19 PM

Basically you'll have to make it so th escript only allows if the referer is the allowed site or if it is blank.
Carbonize
Lazarus Guestbook
A SPADE IS A SPADE - I'm here to help people not to win friends or gain popularity.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users