htaccess issue with hotlinking and seo4smf.

Started by javierjp, August 13, 2008, 08:16:34 PM

Previous topic - Next topic

javierjp

Hi people, first at all, excuse my english.

This problem maybe happened to someone, i have a very big problem with my htaccess  :'(

I experimented this issue when my htaccess has two or more codes from diferent things.

This its the a typical hotlinking code (this one its created by Cpanel)


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.sitio.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.sitio.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]



These code in alone way works like a charm, the problem its when i add more code to the htaccess, for example the seo4smf code:


#Some apache servers need Rewritebase.
#delete # from start of Rewrite base to enable it.
#If your forum is something like http://www.forum-example.com/forum then modify your
#RewriteBase in this way: RewriteBase /forum

RewriteBase /

#Archive/Sitemaps
RewriteRule ^sitemaps-([a-zA-Z0-9-]*)\.html index.php?dummy=1&action=seo4smfsitemaps&sa=$1 [L]

#uncomment if you use beautifying url actions
#RewriteCond %{REQUEST_METHOD} =GET
#RewriteCond %{QUERY_STRING} ^action=(.*)$
#RewriteRule  ^(.*)$ seo4smf-redirect.php?a=%1 [R=301,L]

RewriteCond %{QUERY_STRING} ^topic=([0-9]*)$
RewriteRule  ^(.*)$ seo4smf-redirect.php?t=%1 [R=301,L]

RewriteCond %{QUERY_STRING} ^topic=([0-9]*).([0-9]*)
RewriteRule  ^(.*)$ seo4smf-redirect.php?t=%1.%2 [R=301,L]

RewriteCond %{QUERY_STRING} ^board=([0-9]*).([0-9]*)
RewriteRule  ^(.*)$ seo4smf-redirect.php?b=%1 [R=301,L]

RewriteCond %{QUERY_STRING} ^action=profile;u=([0-9]*);(.*)$
RewriteRule  ^(.*)$ seo4smf-redirect.php?u=%1;param=%2 [R=301,L]

RewriteCond %{QUERY_STRING} ^action=profile;u=([0-9]*)
RewriteRule  ^(.*)$ seo4smf-redirect.php?u=%1 [R=301,L]

#Tiny Portal Old Url's
RewriteCond %{QUERY_STRING} ^page=([0-9]*)
RewriteRule  ^(.*)$ seo4smf-redirect.php?p=%1 [R=301,L]

#Rewrite Old urls
RewriteRule  ^index.php/board,(.*).html seo4smf-redirect.php?b=$1 [R=301,L]
RewriteRule  ^index.php/board,(.*).html;(.*) seo4smf-redirect.php?b=$1&o=$2 [R=301,L]

RewriteRule  ^index.php/topic,(.*).html seo4smf-redirect.php?t=$1 [R=301,L]
RewriteRule  ^index.php/topic,(.*).html;(.*) seo4smf-redirect.php?t=$1&o=$2 [R=301,L]

#Bad Url's
#RewriteCond %{REQUEST_URI} ^(.*)\.html$
#RewriteCond %{REQUEST_URI} !^(.+)/(.*)-t([0-9]*)\.([0-9]*).html$
#RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html seo4smf-redirect.php?t=$2 [R=301,L]

RewriteRule  ^(.*)/-t(.*).html seo4smf-redirect.php?t=$2 [R=301,L]
RewriteRule  ^-b(.*)/$ seo4smf-redirect.php?b=$1 [R=301,L]
RewriteRule  ^-b(.*)/(.*)$ seo4smf-redirect.php?b=$1 [R=301,L]
RewriteRule  ^(.*)/-b(.*)/$ seo4smf-redirect.php?b=$2 [R=301,L]

#New board URL's
RewriteRule ^(.*)-b([0-9]*)\.([0-9]*)/;(.*) index.php?dummy=1&board=$2.$3&$4 [L]
RewriteRule ^(.*)-b([0-9]*)\.([0-9]*)/$ index.php?dummy=2&board=$2.$3 [L]
RewriteRule ^(.*)-b([0-9]*)\.([0-9])$ index.php?dummy=2&board=$2.$3 [L]

#New topic URL's
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html;((\?:from|msg|new)[0-9]*);(.*)$ index.php?dummy=1&topic=$2.$4&$6 [L]
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html;((\?:from|msg|new)[0-9]*) index.php?dummy=1&topic=$2.$4 [L]
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html;(.*)$ index.php?dummy=1&topic=$2.$3&$4 [L]
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html$ index.php?dummy=1&topic=$2.$3 [L]

#New profiles URL's
RewriteRule ^(.*)-u([0-9]*)\.html;sa,(.*);start,([0-9]*);delete,([0-9]*);sesc,([a-z0-9]*)$ index.php?dummy=1&action=profile;u=$2;sa=$3;start=$4;delete=$5;sesc=$6 [L]
RewriteRule ^(.*)-u([0-9]*)\.html;sa,(.*);start,([0-9]*)$ index.php?dummy=1&action=profile;u=$2;sa=$3;start=$4 [L]
RewriteRule ^(.*)-u([0-9]*)\.html;sa,(.*)$ index.php?dummy=1&action=profile;u=$2;sa=$3 [L]
RewriteRule ^(.*)-u([0-9]*)\.html index.php?dummy=1&action=profile;u=$2 [L]

#New Tinyportal Articles URL's
RewriteRule ^(.*)-p([0-9]*)\.html index.php?dummy=1&page=$2 [L]

#New action Url's - uncomment if you use beautifying url actions
#RewriteRule ^(.*)\.html(.*)$ index.php?dummy=1;action=$1;$2 [L]
#RewriteRule ^(.*)\.html$ index.php?dummy=1;action=$1 [L]

#Sitemaps
RewriteRule sitemap.xml sitemaps.php [L]
RewriteRule urllist.txt urllist.php [L]

<IfModule mod_security.c>
# Turn off mod_security filtering.  SMF is a big boy, it doesn't need its hands held.
SecFilterEngine Off

# The below probably isn't needed, but better safe than sorry.
SecFilterScanPOST Off
</IfModule>



after added the seo4smf code or any other code (for example a watermark code)  the hotlinking STOP working, the only way to  get the hotlinking code working its leaving alone in the htaccess file, without any other addon.


Any ideas? i really desesperated because other sites are stealing up to 80gb every month!  :'(
thanks in advance.
best regards.

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Deprecated

First let's start with your deny hotlinking code. I prefer this one myself:


RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(.+\.)sitio\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]


I did notice that your anti-hotlink hadn't escaped the period between stio and com for example. Also note that "RewriteEngine on" should be at the top of your .htaccess file. You might experiment with putting the other three statements last in the file. It could be that later statements are changing your rewrite and removing the hotlinking protection.

The rest... Well I've never seen an .htaccess file that big! I noticed there is at least one section that is duplicated:


#Rewrite Old urls
RewriteRule  ^index.php/board,(.*).html seo4smf-redirect.php?b=$1 [R=301,L]
RewriteRule  ^index.php/board,(.*).html;(.*) seo4smf-redirect.php?b=$1&o=$2 [R=301,L]

RewriteRule  ^index.php/topic,(.*).html seo4smf-redirect.php?t=$1 [R=301,L]
RewriteRule  ^index.php/topic,(.*).html;(.*) seo4smf-redirect.php?t=$1&o=$2 [R=301,L]


Other statements appear to be dummy examples.


#New board URL's
RewriteRule ^(.*)-b([0-9]*)\.([0-9]*)/;(.*) index.php?dummy=1&board=$2.$3&$4 [L]
RewriteRule ^(.*)-b([0-9]*)\.([0-9]*)/$ index.php?dummy=2&board=$2.$3 [L]
RewriteRule ^(.*)-b([0-9]*)\.([0-9])$ index.php?dummy=2&board=$2.$3 [L]

#New topic URL's
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html;((\?:from|msg|new)[0-9]*);(.*)$ index.php?dummy=1&topic=$2.$4&$6 [L]
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html;((\?:from|msg|new)[0-9]*) index.php?dummy=1&topic=$2.$4 [L]
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html;(.*)$ index.php?dummy=1&topic=$2.$3&$4 [L]
RewriteRule ^(.*)-t([0-9]*)\.([0-9]*)\.html$ index.php?dummy=1&topic=$2.$3 [L]


Or maybe I just don't understand them. My advice is that you should start out with your hotlink protection and add the most important thing from the other file. If hotlink protection still works then add another section, and so on. Don't add anything you don't really need.

In .htaccess files, size doesn't count. In fact the best .htaccess files are the shortest ones. Why don't you try my advice and then after experimenting a bit post back and tell us how you are going.


Remember: "RewriteEngine on" comes first, and should appear only once. Also the # indicates a comment line.

Advertisement: