: Restrict direct folder access via .htaccess except via specific links I want to restrict access to a folder on my server so that visitors may only access the contents (a web application) via
I want to restrict access to a folder on my server so that visitors may only access the contents (a web application) via links in the same domain. Can I do this using .htaccess? To be clear, I simply want to prevent direct access to the contents so that visitors are routed through other pages on my website in order to get there.
More posts by @Kevin317
1 Comments
Sorted by latest first Latest Oldest Best
I think something like this might work:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+.)?YOURDOMAIN.com [NC]
RewriteCond %{REQUEST_URI} ^/PROTECTEDFOLDER/.*$ [NC]
RewriteRule ^(.*)$ "http://www.YOURDOMAIN.com/" [R=301]
I'm haven't tried this, but it should work. Some explanation:
If the referrer is not from your domain, or a subdomain...
If the folder "PROTECTEDFOLDER" is being accessed...
Redirect to your homepage.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.