Forum Moderators: phranque

Message Too Old, No Replies

Why is my hotlinking and caching code not working?

Hotlinking and caching code not working with the existing code

         

Mikroz

9:22 am on Mar 31, 2011 (gmt 0)

10+ Year Member



Hi all,

I have tried multiple htaccess samples found online, on different URLs and tested them with different online services.

I cannot get my hotlinking or caching code to work.

I've tried placing the code in the root and in the subdirs - the different URLs. No difference.

Below is my root .htaccess - I've removed the extra code that to my mind can't affect the problem at hand.


# Deny all .htaccess, .DS_Store, ._* (resource fork) files
<Files ~ "^\.([Hh][Tt]|[Dd][Ss]_[Ss]|[_])">
Order allow,deny
Deny from all
Satisfy All
</Files>

# deny access to all .log and .comment files
<Files ~ "^.*\.([Ll][Oo][Gg]|[cC][oO][mM][mM][eE][nN][tT])">
Order allow,deny
Deny from all
Satisfy All
</Files>

# Deny access to .ht*
#<Files ~ "^\.ht">
#order allow,deny
#deny from all
#</files>

# Allow access to all
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>

# Access types allowed
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>

# Disable all indexing
Options All -Indexes

################################################## CACHING BELOW

Header unset ETag
FileETag None

# MONTH
#<FilesMatch "\.(flv|gif|jpg|jpeg|png|bmp|ico|swf)$">
#Header set Cache-Control "max-age=2592000"
#</FilesMatch>

# WEEK
#<FilesMatch "\.(js|css|pdf|txt)$">
#Header set Cache-Control "max-age=604800"
#</FilesMatch>

# DAY
#<FilesMatch "\.(html|htm|php)$">
#Header set Cache-Control "max-age=43200"
#</FilesMatch>

##################################################

# Engine
RewriteEngine On
Options +FollowSymLinks
RewriteBase /

# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]

# Root redirect exclusions
# Exclude hostnames "(www.)example.co.za" and blank
RewriteCond %{HTTP_HOST} !^((www\.)?exquisiteinteriors\.co\.za\.?(:[0-9]+)?)?$
RewriteCond %{HTTP_HOST} !^((www\.)?justride\.za\.net\.?(:[0-9]+)?)?$
RewriteCond %{HTTP_HOST} !^((www\.)?kombination\.za\.org\.?(:[0-9]+)?)?$
RewriteCond %{HTTP_HOST} !^((www\.)?trekairways\.za\.org\.?(:[0-9]+)?)?$
RewriteRule ^(.*)$ [blog.the3rdrock.com...] [R=301,L]

################################################## HOTLINKING BELOW

# Hotlinking
#RewriteCond %{HTTP_REFERER} !^$
#RewriteCond %{REQUEST_FILENAME} -f
#RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$ [NC]
#RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?the3rdrock\. [NC] [OR]
#RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?exquisiteinteriors\. [NC] [OR]
#RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?justride\. [NC] [OR]
#RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?kombination\. [NC] [OR]
#RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?trekairways\. [NC]
#RewriteRule \.(gif|jpe?g?|png|bmp|ico|swf|pdf)$ - [F,NC,L]


Yes, I know the caching and hotlinking code is commented out. This was taken from my live file, so the broken code has been disabled.

After ages spent studying this, I am still lost.

Please - what am I missing? :D

Many thanks,

Nic

wilderness

2:02 pm on Mar 31, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There a simultaneous thread which addresses this same topic and which you should have read before duplicating the same request.

I found my .HTACCESS File [webmasterworld.com]

Furthermore, rather than copying and pasting multiple lines (badly syntax'd) from various sources, I'd suggest that you make a valid attempt to comprehend how these procedures work and how you might combine the actions of the multiple lines that you've copied and pasted into lesser lines that would function more efficiently and be easier for you (or anybody else) to interpret as time passes.

The Forum Library [webmasterworld.com] is an excellent source for many needs.

Mikroz

10:04 am on Apr 1, 2011 (gmt 0)

10+ Year Member



Hi wilderness,

I've now read the topic in your reply, but it still hasn't helped me.

I realize my file is a big mashup of what I've come across and been able to slightly edit, but I am not yet able to write most of this stuff from scratch.

I've also spent most of the night and this morning trying to see what could be made more concise, etc. Short of a few edits I've not managed to combine most of it.

Lastly, I removed chunks of the file at a time and then uploaded it for testing.

None of the code I removed made any noticeable differences.

For some reason none of the caching commands or the hotlinking commands I've come across are working. It's quite bizarre - unless I'm missing something obvious to someone more skilled than I?

Regards,

Nic

wilderness

1:27 pm on Apr 1, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've now read the topic in your reply, but it still hasn't helped me.


1) See the 3rd response in that thread from g1smd
2) start with those basic three lines. Test to see if those three lines function.
4) supplement your additional lines and text after each individual addition, and until you find the line that is not working.

g1smd

1:26 am on Apr 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Additionally,

[NC] [OR] should be [NC]

[F,L] should be [F]

[F,NC,L] should be [F,NC]

Mikroz

4:18 am on Apr 5, 2011 (gmt 0)

10+ Year Member



Thanks g1smd. :)

I'll give that a try later today.

Mikroz

6:07 am on Apr 5, 2011 (gmt 0)

10+ Year Member



Still battling.

I've tried the code on a few different domains residing on the server in question.

I even tried running just that code in the .htaccess

I'm going to put a support request in with my host. Clearly I'm overlooking something specific to this setup.

Thanks for your help. :)

Nic