Forum Moderators: phranque
I want to dissalow direct linking from a particular folder. That's easy enough, but what I want to do is if someone is requesting the image bush.jpg -- I want to send them to www.url.com/show.php?=bush.jpg.
I know you can use wild cards in .htaccess, but I have been unable to figure this out. Any help would be much appreciated, Thank you.
My .htaccess file is as follows:
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} .*jpg$¦.*jpeg$¦.*gif$¦.*png$ [NC]
RewriteCond %{HTTP_REFERER} !example\.net [NC]
RewriteCond %{HTTP_REFERER} !greg\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /img.php?img=$1
Now, if I go to http://www.example.net/img/_full/Bluehills.jpg I am indeed fed the page from http://www.example.net/img.php?img=Bluehills.jpg.
When I view the page though, all formatting is lost. It does not load my style sheet, favicon etc.
Someone please help a noob?
[edited by: jdMorgan at 12:48 am (utc) on Sep. 30, 2005]
[edit reason] Examplified URLs & de-linked [/edit]
Welcome to WebmasterWorld!
This is not a busy forum, so please be patient for replies. :)
Here's a clean-up of your code. It also makes provisions for users behind caching proxies, such as AOL and many corporate networks by allowing for blank referrers:
RewriteEngine On
#
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !example\.net [NC]
RewriteCond %{HTTP_REFERER} !greg-j\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule ^([^.]+\.(jpe?g¦gif¦png))$ /img.php?img=$1 [NC,L]
Jim