Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

htaccess Url access only from within website?

Status
Not open for further replies.

butteryak

IS-IT--Management
Feb 1, 2012
3
US
I'm wondering how to go about restricting a page on my website so that it can only be accessed from within the website. Example.
User goes to On that page is a (relative)link to User clicks on that link and is directed to
Access to this page is only possible from a relative link. <example.html>

User cannot access this page by typing
Not sure if this is possible or not. Thanks for any help!
 
I think using HTTP_REFERER might work. Perhaps something like this. I haven't tested it - you might need to put restricted into its own directory and apply the .htaccess file there.

Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !([URL unfurl="true"]www.)?example.com/restricted.html[/URL]
RewriteRule .* - [F]
 
thanks much for your input. This just blocks the whole site. the issue i may be running into with this is that technically the directory does not exist. it is dynamically created with php. I am working on a php solution though using http_referer. I can get the referer info using

isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; which returns the previous page the user has come from.

which I can use to compare to an accepted value and then redirect to an access denied page if the proper refered page is not the result.

this method should work. perhaps....just have to exercise my PHP skills a bit :)

 
The PHP method worked for what I need to do, Thanks much for pointing me in the HTTP_REFERER direction!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top