[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] Re: mod_rewrite question



RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://darksites.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.darksites.com/ [NC]
RewriteRule [^/]+\.(gif|jpg)$ http://www.darksites.com/index.shtml [L,R]


Thats kind of a hard one. Easiet solution I have is for you to have all of
your images one directory and add the rewrite code you have above to that
directory and put the banner images in perhaps your / root directory and
remove the above code from the .htaccess in the /root directory. If you've
already given your banner links out and don't want to change your directory
then maybe you could move you images to a new directory. BTW here a trick so
you don't have to put two seperate lines for yourdomain.com and
www.yourcomain.com on the Rewrite Cond:

RewriteCond %{HTTP_REFERER} !^http://([a-z0-9-]+\.)*darksites.com/ [NC]

Note that by adding this: ([a-z0-9-]+\.)*   in front of your domain that
will make it look for *.darksites.com which could include the darksites.com,
www.darksites.com , video1.darksites.com etc.  Saves a little space and
speeds up the server by a millionth of a second by not having to read
another line :>

I didn't know about the RewriteRule [^/]+\.(gif|jpg)$
http://www.darksites.com/index.shtml [L,R] line to include both gif & jpg in
the same sweep.  I've always used this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$        (This line allows you to type the
filename directly in the browser, if you remove then the file has to be
called by your domain)
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ [NC]
RewriteRule .*\.gif$ - [F]

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://ebonyhq.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://64.40.192.13/.*$ [NC]
RewriteRule .*\.jpg$ - [F]

Note that the [F] means to give it a forbidden error instead of your [R,L]
which redirects a page.
So if I have this set up in .htaccess then any <img
src=yourdomain/images.jpg> will result in the image simply not appearing as
the image didn't exist. If you type it directly in the browser, you'll
simply get a 300 Forbidden error.

Attachment: smime.p7s
Description: S/MIME cryptographic signature