Limiting access to one directory when on subdomain
Howdy, I need to do the following:
- allow access to sub.domain.com/directory from www.domain.com (linking to an asset)
- prevent access to sub.domain.com/* (Return a 404 page when开发者_开发知识库 user hits subdomain directly
Is this possible using htaccess and, if so, any pointers on how to accomplish it?
Thanks
Using .htaccess you might want to look up htaccess and regex tutorials as they are of great help.
Stop sites from hotlinking is what I assume you are referring to therefore: you need to enable mod_rewrite and add this to the .htaccess file in the domain's root directory (with a little of what you learn):
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?domain\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://www.domain.com/noHotlink.gif
This should point you in the right direction towards how to do it.
精彩评论