Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Trouble with some rewriting rules
Some weeks ago I’ve started to use some rewriting rules to prevent Hotlinking to my Portfolio images.
Everything works well except a detail that I discovered today:
if you access my website using http://alexdukal.com the rewrite engine start working and you can’t see the main images as if you go http://www.alexdukal.com … that’s a bad thing!
This is the .htaccess content:
<code>RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www.)?alexdukal.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://alexdukal.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?adukal.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !google. [NC]
RewriteCond %{HTTP_REFERER} !yahoo. [NC]
RewriteCond %{HTTP_REFERER} !altavista. [NC]
RewriteCond %{HTTP_REFERER} !archive.org [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?search\?q=cache [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|bmp|png)$ /images/hotlinking.jpg [L]</code>
What’s wrong? How to improve it?
Thx in advance!
Offline
#2 2006-12-12 13:53:19
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Trouble with some rewriting rules
You are missing some backslashes.
RewriteCond %{HTTP_REFERER} !^http://(www\.)?alexdukal\.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?adukal\.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
RewriteCond %{HTTP_REFERER} !altavista\. [NC]
RewriteCond %{HTTP_REFERER} !archive\.org [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(bmp|gif|jpe?g|png)$ /images/hotlinking.jpg [NC,L]
And make sure these rules appear before the Txp rules in your .htaccess.
Offline
Re: Trouble with some rewriting rules
Thx Mary. I’m going to make a new try right now!
Anyway I’m using this .htaccess inside the images folder not with the main txp .htaccess
See ya’
Offline
Re: Trouble with some rewriting rules
Nope! The problem is still the same … :-(
Offline
Re: Trouble with some rewriting rules
Hi Duchamp.
Try to rewrite all the URLs like alexdukal.com to www.alexdukal.com.
I use something like this in my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^alexdukal\.com$ [NC]
RewriteRule ^(.*)$ http://www.alexdukal.com/$1 [R=301,L]
...
...
Hope that helps.
Saludos!
Offline
Re: Trouble with some rewriting rules
That works very well!
Thanks a lot maniqui
Offline
Pages: 1