Forum Moderators: phranque
[webmasterworld.com...]
However in order to allow hotlinking on one folder they use a workaround to turn off the rewrite engine for that folder.
Ideally I have some other rewrite rules I need to apply to that folder so I cant turn the engine off.
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http(s)?://(www\.)?domain1 [NC]
RewriteCond %{HTTP_REFERER}!^http(s)?://(www\.)?domain2 [NC]
RewriteCond %{HTTP_REFERER}!^http(s)?://(www\.)?domain3 [NC]
RewriteRule \.(jpg¦jpeg¦png¦gif¦swf¦css)$ [domain1...] [NC,R,L]
Is this just added afterwards?
RewriteCond %{REQUEST_URI}!^/f/
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/f/
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain1 [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain2 [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain3 [NC]
RewriteRule \.(jpe?g¦png¦gif¦swf¦css)$ /f/block.gif [NC,L]
I changed '!^$' to '.' and 'jpg¦jpeg' to 'jpe?g' for the sake of efficiency -- they are completely equivalent.
Jim
If it helps my full .htaccess is:
Options -Indexes
Options +FollowSymLinks
RewriteEngine OnRewriteCond %{REQUEST_URI} !^/f/
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?examp.org.uk [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.net [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.org.uk [NC]
RewriteRule \.(jpe?g¦png¦gif¦swf¦css)$ /f/block.gif [NC,L]
RewriteCond %{HTTP_HOST} ^www\.example\.org.uk$ [NC]
RewriteRule ^(.*)$ http://example.org.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*)old_domain.com [NC]
RewriteRule ^(.*)$ http://example.org.uk/ [R=permanent]
[edited by: jdMorgan at 4:11 pm (utc) on Jan. 7, 2006]
[edit reason] No URLs, please. See Terms of Serivce. [/edit]
I'd write it like this:
Options +FollowSymLinks -Indexes
RewriteEngine on
#
RewriteCond %{REQUEST_URI} !^/f/
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?(examp\.org\.uk¦example\.net¦example\.org\.uk) [NC]
RewriteRule \.(jpe?g¦png¦gif¦swf¦css)$ /f/block.gif [NC,L]
#
RewriteCond %{HTTP_HOST} ^www\.example\.org\.uk [NC,OR]
RewriteCond %{HTTP_HOST} old_domain\.com [NC]
RewriteRule (.*) http://example.org.uk/$1 [R=301,L]
If you get an error, please post the relevant lines from your server error log file.
Be sure to flush your browser cache between tests, and change all broken pipe "¦" characters to solid pipes before trying to use this code; posting on this board modifies that character.
Jim
I cleared the browser cache (Ctrl + F5)
I then accessed another webpage that I made which has my site images from a domain that wasn't allowed (using FF 1.5)
All images were displayed.
The only error I have found is that cpanel has:
[Sat Jan 7 05:50:15 2006] [alert] [client 81.153.27.47] /home/huwnet/public_html/.htaccess: RewriteCond: bad argument line '%{REQUEST_URI}!^/f/'\n
In the error log
Sorry to sound stupid but I didn't get the bit about pipes
> RewriteCond: bad argument line '%{REQUEST_URI}!^/f/'\n
There's a space missing between the "}" and the "!" in that line of your code then.
Jim