idanan Posted July 19, 2005 Posted July 19, 2005 Hi, I enabled hotlink protection and listed my own sites and subdomains as exceptions. That worked: the cpanel modified my .htaccess in public_html to include all the names of my site and its subdomains. Now I want to allow images in a specific directory (to be created) to be hotlinked too (I can't tell which domain will load them). How do I edit my .htaccess to do that? Another thing I noticed is that this setting seems to be inherited in subdirectories. Specifically, my .htaccess in public_html affects (prevents hotlinking) to images in itself and subdirectories (such as public_html/images) but the .htaccess in the images does not include the inherit directive or a copy of the rewrite rules from the .htaccess in public_html. How does that work? Thanks in advance, - Itai Quote
TweezerMan Posted July 19, 2005 Posted July 19, 2005 I enabled hotlink protection and listed my own sites and subdomains as exceptions.That worked: the cpanel modified my .htaccess in public_html to include all the names of my site and its subdomains. Now I want to allow images in a specific directory (to be created) to be hotlinked too (I can't tell which domain will load them). How do I edit my .htaccess to do that? <{POST_SNAPBACK}> Depending on what's exactly in the .htaccess file in your public_html directory, the 'images' directory you want to create may already have hotlink protection. Another thing I noticed is that this setting seems to be inherited in subdirectories.Specifically, my .htaccess in public_html affects (prevents hotlinking) to images in itself and subdirectories (such as public_html/images) but the .htaccess in the images does not include the inherit directive or a copy of the rewrite rules from the .htaccess in public_html. How does that work? <{POST_SNAPBACK}> When a web page is requested, the web server begins at the public_html directory and reads the .htaccess file there, then proceeds to read the .htaccess file in every subdirectory leading to the actual file that was requested. A directive specified in a subdirectory will take precedence over that same directive specified in a parent directory. That's about all there is to it! Quote
idanan Posted July 20, 2005 Author Posted July 20, 2005 Depending on what's exactly in the .htaccess file in your public_html directory, the 'images' directory you want to create may already have hotlink protection.When a web page is requested, the web server begins at the public_html directory and reads the .htaccess file there, then proceeds to read the .htaccess file in every subdirectory leading to the actual file that was requested. A directive specified in a subdirectory will take precedence over that same directive specified in a parent directory. That's about all there is to it! <{POST_SNAPBACK}> Hi again, I think I was not clear enough. Let me try again: - Hotlink protection was enabled in cpanel. - All directories are now automatically protected (because of the parent dir) - I wish to create a new directory that will NOT be protected. According to your reply, I must put an .htaccess to _remove_ hotlink protection in the new directory. The question then is: What is the opposite of the following rewrite rule taken from the parrent dir? RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://www.neocamera.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.neocamera.com$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC] Thank you in advance, - Itai Quote
TCH-Thomas Posted July 20, 2005 Posted July 20, 2005 Please note while reading this that I have no clue if this work... I checked the hotlink section in cpanel, and it looks to like you can enter the directory that you want to have access, manually and not only having to accept the ones cpanel enters itself. Quote
Striver Posted July 20, 2005 Posted July 20, 2005 The following code in my .htaccess file prevents linking to images from any site other than verchi.com but exempts the sub folders /selling and /test from that prohibition. images in those folders can be linked to from anywhere... >RewriteEngine on RewriteCond %{REQUEST_URI} ^/selling RewriteCond %{REQUEST_URI} ^/test RewriteRule ^.*$ - [L] RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://verchi.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://verchi.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.verchi.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.verchi.com$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.verchi.com/images/image.gif [R,NC] Quote
idanan Posted July 21, 2005 Author Posted July 21, 2005 The following code in my .htaccess file prevents linking to images from any site other than verchi.com but exempts the sub folders /selling and /test from that prohibition. images in those folders can be linked to from anywhere... >RewriteEngine on RewriteCond %{REQUEST_URI} ^/selling RewriteCond %{REQUEST_URI} ^/test RewriteRule ^.*$ - [L] RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://verchi.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://verchi.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.verchi.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.verchi.com$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.verchi.com/images/image.gif [R,NC] <{POST_SNAPBACK}> Thanks a lot! That was exactly what I needed! - Itai Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.