Jump to content

Recommended Posts

Posted

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

Posted
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?

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?

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! :lol2:

Posted
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!  :)

 

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

Posted

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.

Posted

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]

Posted
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]

 

Thanks a lot! That was exactly what I needed! :D

 

- Itai

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...