Any mod_rewrite wizards here?

Status
Not open for further replies.

spyderman4g63

New member
Mar 8, 2007
313
2
0
Ohio
www.teamtutorials.com
I am having trouble modifying my .htaccess file. I am using this code right now to redirect url's so they are "clean":

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L,QSA]
</IfModule>

What I want to do is enable hot link protection because I am getting quite a few bandwidth theives lately. If I use just this code in my .htaccess file the hotlink image works:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://teamtutorials.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://teamtutorials.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.teamtutorials.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.teamtutorials.com$ [NC]
RewriteRule .*\.(.+)$ /hotlink.jpg [R,NC]

The problem is I don't know how to combine the two. If I put them both in the .htacess file, the hot link protection doesn't display any images on the abusers page (original image or protect image). The url rewrite still works fine though. I really want to goatse these guys who are stealing my images. Thanks for the help in advanced.
 


Solution

This is what I came up with. It seems to be working so far.

<IfModule mod_security.c>
SecFilterScanPOST off
</IfModule>

<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L,QSA]
</IfModule>

#hotlink protection
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?teamtutorials.com/.*$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ http://www.csswv.com/hotlink/teamtutorials.jpg [R,NC]
 
Status
Not open for further replies.