Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-12-12 13:30:58

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

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

#3 2006-12-12 14:14:38

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

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

#4 2006-12-12 14:19:05

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Re: Trouble with some rewriting rules

Nope! The problem is still the same … :-(

Offline

#5 2006-12-12 14:42:40

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2006-12-12 14:59:55

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Re: Trouble with some rewriting rules

That works very well!
Thanks a lot maniqui

Offline

Board footer

Powered by FluxBB