Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-15-2009, 10:15 PM   #1
LQ Newbie
Registered: Jun 2007
Posts: 16

Rep: Reputation: 0
Linking to a website only through another site


I have two websites: Website1 and Website2

I would like to prevent people from linking directly to Website2 by writing its URL in a browser. However, I would like them to have access to Website2 by clicking on a link in Website1. In other words, if the referrer is Website1 then access to Website2 is ok. Otherwise, I would like to block all other referrers, including people typing a URL directly into a browser.

I believe it is possible to control access through .htaccess. Would someone please point me to some code I could implement in .htaccess or somehow otherwise restrict access as indicated above?

BTW I have tried using deny and allow but that only seems to apply to addresses typed in the browser. I believe there is an answer which uses the rewrite engine but I have not been able to find the correct code anywhere.

Thank you very much.
Old 05-16-2009, 10:01 AM   #2
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,900

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
You can use mod_rewrite to allow/deny access based on referrer. In your case you can use something like:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://website1/special-link-page.html
RewriteRule (.*) - [F]
Old 05-16-2009, 10:27 AM   #3
LQ Newbie
Registered: Jun 2007
Posts: 16

Original Poster
Rep: Reputation: 0
Thank you. I appreciate it so much - it seems to work perfectly.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to block all website traffic for few IP but they will brows only 1 site aronnok Linux - Networking 1 05-22-2008 10:30 AM
Problem in using both load time linking and runtime linking durgaprasad_j Linux - General 0 08-01-2006 04:49 AM
Protecting the content of your website from remote/direct linking Basel Programming 4 01-26-2006 10:35 PM
localhost:901 gets redirected to "Power Linking" web site advertisement condosolon Linux - Newbie 2 03-04-2004 01:23 PM
how to protect images linking from other website adrianmak Linux - Software 9 10-19-2003 08:43 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration