![]() |
Does anyone know the htaccess code that...
I need the htaccess code (if there is one) that doesn't allow .jpg or .gif images to be displayed on their own.
I only want them to be displayed on an html page. |
Make sure you have mod rewrite.
Rewriteengine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ "NC" RewriteRule .*\.(gif|GIF|jpg|JPG)$ - "F" |
But isn't that just for anti hotlinking? I used that code and I still can see the image. What I want is the code that does not show the image unless it's on an HTML page.
If that's even possible. |
an HTML page is just a bunch of scripting that tells the browser what to display. When your browser sees an image, it grabs the image. In order to do what you want, from what I know, is to have a script READ the image from a non-web accessible directory and spit the contents to the browser.
|
AAhhhh.. that makes sense. Cool man, thanks.
A non-web accessible browser,... I didn't even think of doing it that way. Thanks. :) edit... Ok, so how do I call into a non-web accessible directory? |
depends on languages, etc. I do lots of php so I use fopen() or something similiar and pass it the path to the image i want to read. I also do this to create images with custom text based on an image template. perhaps someone else out there knows a better method.
|
Quote:
Or just use that without the RewriteCond %{HTTP_REFERER} !^$ which allows direct linking. The quotes around NC and F should be square braces though. No need to dick around with anything else or any kind of scripting. |
Quote:
|
Quote:
|
AuthUserFile /dev/null
AuthGroupFile /dev/null AddHandler server-parsed .html RewriteEngine On RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://www.YOUR-URL.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://YOUR-URL.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.YOUR-URL.com:80/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://YOUR-URL.com:80/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://XXX.XXX.XXX.XXX/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://XXX.XXX.XXX.XXX:80/.*$ [NC] RewriteRule .*\.jpg$ http://www.YOUR-URL.com [R,L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://www.YOUR-URL.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://YOUR-URL.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.YOUR-URL.com:80/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://YOUR-URL.com:80/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://XXX.XXX.XXX.XXX/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://XXX.XXX.XXX.XXX:80/.*$ [NC] RewriteRule .*\.gif$ http://www.YOUR-URL.com [R,L] ErrorDocument 400 http://www.YOUR-URL.com/404/404.htm ErrorDocument 401 http://www.YOUR-URL.com/404/404.htm ErrorDocument 403 http://www.YOUR-URL.com/404/404.htm ErrorDocument 404 http://www.YOUR-URL.com/404/404.htm ErrorDocument 500 http://www.YOUR-URL.com/404/404.htm REPLACE XXX.XXX.XXX.XXX 's WITH YOUR ip hit enter 1 or 2 times after the last line IMPORTANT transer it in ASCII |
yep you didn't clear your cache .
|
| All times are GMT -7. The time now is 11:43 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123