Forum Moderators: phranque
DirectoryIndex /hotlink/index.html
RewriteEngine on
RewriteBase /hotlink/
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.jpg$" [NC]
RewriteRule ([^/.]+)\.jpg$ is_jpg.gif [L]
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.png$" [NC]
RewriteRule ([^/.]+)\.png$ is_png.gif [L]
# RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.gif$" [NC]
# RewriteRule ([^/.]+)\.gif$ is_gif.gif [L]
RewriteRule ([^/.]+)\..* is_NOT_image.gif [L]
mydomain.com/hotlink/image.jpg , ,sends ‘is_jpg.gif’
mydomain.com/hotlink/image.png , sends ‘is_png.gif’
mydomain.com/hotlink/image.gif , , sends ‘is_NOT_image.gif’
mydomain.com/hotlink/what-ever , , sends ‘is_NOT_image.gif’
mydomain.com/hotlink/image.jpg , ,sends ‘is_gif.gif’
mydomain.com/hotlink/image.png , sends ‘is_gif.gif’
mydomain.com/hotlink/image.gif , , sends ‘is_gif.gif’
mydomain.com/hotlink/what-ever , , sends ‘is_gif.gif’
I have learned not to mix “mod_setenvIf” and “mod_rewrite”! So I am back to the basic with only the mod_rewrite
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.jpg$" [NC]
RewriteRule ([^/.]+)\.jpg$ is_jpg.gif [L]
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.png$" [NC]
RewriteRule ([^/.]+)\.png$ is_png.gif [L]
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.gif$" [NC]
RewriteRule ([^/.]+)\.gif$ is_gif.gif [L]
"image.jpg".jpg , "is_jpg".gif : dark / light turquoise
"image.png".png, "is_png".gif : dark blue / lavender
"image.gif".gif , , "is_gif".gif : brown / antiquewhite
whatever.bla, "is_NOT_image".gif: brown / dark orange
RewriteCond %{REQUEST_URI} !"[a-z0-9_-]+\.gif$" [NC]
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.jpg$" [NC]
RewriteRule \.jpg$ is_jpg.gif [L]
# "image.jpg".jpg »»» "is_jpg".gif == OK
RewriteCond %{REQUEST_URI} !"[a-z0-9_-]+\.gif$" [NC]
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.png$" [NC]
RewriteRule \.png$ is_png.gif [L]
# "image.png".png »»» "is_png".gif == OK
OR
RewriteRule \..* is_NOT_image.gif [L]
# image*.* »»» is_NOT_image.gif == ?
RewriteCond %{REQUEST_URI} !"[a-z0-9_-]+\.jpg$" [NC]
RewriteCond %{REQUEST_URI} !"[a-z0-9_-]+\.png$" [NC]
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.gif$" [NC]
RewriteRule \.gif$ is_gif.gif [L]
# image*.* »»» is_gif.gif == ?
DirectoryIndex index.html
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?subdomain.mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?community.com/l.php\?.*$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^communityexternalhit/.*$ [NC]
RewriteRule .*\.(gif|png|jpe?g|eot|woff|svg|ttf|mp3|flv|avi|wmv|mp4|swf|mpe?g|asf|mov)$ animated_promotion_of_my_site.gif [L]
# Great! You wanna steal my stuff? Here's my banner instead!
!^http://(www\.)?subdomain.mydomain.com/.*$
!^http://(www\.)?mydomain.com/.*$
into
!^http://(www\.)?(subdomain\.)?mydomain.com/.*$
RewriteRule ^(.*)\.(gif|jpe?g|png)$ httq;//%{HTTP_HOST}/path/to/hotlink.php?url=$1.$2 [R,NC,L]
# © Elvis Presley, from his song “Return To Sender”, ha ha ha!
RewriteCond %{HTTP_USER_AGENT} ^communityexternalhit/.*$ [NC]
RewriteRule [^/.]+ mainImage.png [L]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?community.com/.*$ [NC]
RewriteRule ^.*$ index.html [L]
httq;//www.community.com/l.php?u=http%3A%2F%2Fsubdomain.mydomain.com%2FimageMedia.file&h=.*
into
httq;//www.community.com/l.php?u=http%3A%2F%2Fsubdomain.mydomain.com%2F&h=.*
DirectoryIndex index.html
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?subdomain.mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.*$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^communityexternalhit/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?community.com/l.php\?.*$ [NC]
RewriteRule .*\.(gif|png|jpe?g|eot|woff|svg|ttf|mp3|flv|avi|wmv|mp4|swf|mpe?g|asf|mov)$ animated_promotion_of_my_site.gif [L]
RewriteCond %{HTTP_USER_AGENT} ^communityexternalhit/.*$ [NC]
RewriteRule [^/.]+ mainImage.png [L]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?community.com/.*$ [NC]
RewriteRule ^.*$ index.html [L]
!^http://(www\.)?(subdomain\.)?example.com/.*$ !^http://(www\.)?(subdomain\.)?example\.com/ .*$ - is redundant on the end of all of the conditions. ^(.*) is an error, use ^(([^/]+/)*[^/.]+) instead. .*$ - is redundant on the end of all of the conditions. .*$ - is redundant on the end of all of the conditions.
RewriteCond %{REQUEST_URI} !"[a-z0-9_-]+\.gif$" [NC]
RewriteCond %{REQUEST_URI} "[a-z0-9_-]+\.jpg$" [NC]