Log in

View Full Version : .htaccess problem



feeleash
05-19-2006, 01:54 PM
I'm not sure if anyone has that same problem or posted it here before me but I searched the net and null! I have made a page using ajax java and all that web page in web page tricks but now I want to protect images etc adding .htaccess to the folders. The thing is that I want all those pics to be shown when someone enters from index.html or a page within my site and frobid users to type the path in explorer to view images and sounds... Can this be done with .htaccess? If yes how? :confused:

Twey
05-19-2006, 01:55 PM
It cannot be done, full stop. If you publish the images, then they can be copied, saved, whatever. Copyright them.

feeleash
05-19-2006, 01:58 PM
but I've seen websites which publish images but when you type the image's link it displays Forbidden you cannot enter this folder etc. How do they do that? :confused:

Twey
05-19-2006, 02:05 PM
It's called hotlink protection. The idea is to stop other sites stealing your bandwidth by display images hosted on your server. It's not a form of copy protection, and shouldn't be mistaken as such.

feeleash
05-19-2006, 02:50 PM
So how does this work? What should I do? Get in touch with my web hosts and have them make that protection or do I have to create it?

Twey
05-19-2006, 03:12 PM
It would look something like this:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://yourdomain.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]

feeleash
05-19-2006, 03:15 PM
this would work on my online site and allow the images to be viewed only within my site right? But how can I modify those lines to work for apache (I test my page before uploading it so I wanted to test it on http://localhost/folder/) The thing is that I want images sounds etc work on my page only when activated by a link or java image viewer but if someone places the folder's url in the browser, they will be prompted that they do not have access. I'm knda new to this and I'm not quite sure how this is possible. I tried the lines you gave me but then the images could not be viewed from java image viewer...

Twey
05-19-2006, 04:12 PM
Aaah, I see. Just the folder's URL. In that case, simply remove read permission from the folders. Leave execute permission on, however.

feeleash
05-19-2006, 05:00 PM
Read perimission? I must bore you to death with all those questions but like I said I'm new! :D

Twey
05-19-2006, 05:08 PM
If you're using *n?x, it'd be
chmod go-x <directory>If you're using Windows, there's a long, complex and utterly painful method involving a hidden menu and a couple of buttons whose location I really can't remember now. And it won't work if you're using XP Home or anything before NT.

feeleash
05-19-2006, 05:11 PM
Unfortunately I'm using windows xp pro sp1... can you point me some links to read about it? Thank you for your time...

feeleash
05-19-2006, 05:30 PM
Nevermind found it! Thank you for your help!