News:

Click here for Toll-Free Service for your business starting at $2.00 per month

Main Menu

htaccess

Started by infinity, November 28, 2005, 01:07:40 AM

Previous topic - Next topic

infinity

Hiya

I seem to have run into a small problem but that could be me just so I'm not sure.

Anyway I have a htaccess file in my root directory to stop direct linking however it is not working.

I also have some in folders to prevent viewing the index and that is working.

So my problem is how do I get the htaccess to work for the direct linking???

I don't want to open my site until I can get it to work

Thanks for any help.

webzone (archived)

not sure what you mean by direct linking... if you mean hotlinking (another site using your image inside their page), it is getting harder to block.

many software and devices are now removing or garbling the referer header which is used to allow or block hotlinking. i must also say that blocking hotlinking may cause problems with google image search.

i know this info won't help you a lot, but it may help you reconsider this "protection" which is generally useless.

infinity

Hiya

Sorry I did mean hotlinking. it worked before on the other freepgs system not sure why it's not working now.


ghost

It possible that you were on Plesk lasttime? Maybe thats why its not working this time...
- Ghost -

infinity

Ive never been on the plesk system.
Im talking about the sites hosted on freepgs.com

Htaccess to stop hotlinking worked on the system before the fire but now its not.
I thought it was my cache so I cleaned it out but still no good, I even uploaded a image that has not been viewed by my browser and still it does not work it was able to be hotlinked.

Thanks

Ben

Could you post the .htaccess file (at least the part you're using for the hotlinking...)
--Ben
Ben@freepgs.com

infinity

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?freepgs.com/pinkness/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?freepgs.com/pinkness.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

Ben

Not sure if this is the only error, but I fixed one.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?freepgs.com/pinkness/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?freepgs.com/pinkness.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F,L]
--Ben
Ben@freepgs.com

infinity

Hi

I tried it with your fix but still the same no change. I honestly donnt know whats up with it.
Does the server allow mod rewrite?

Thanks

webzone (archived)

#9
mod_rewrite is enabled.

Changes I made in the code below :
- Added an [OR] between two RewriteCond
- Simplify your rewrite code a bit so it will run faster
- Added PNG as a protected extension

Try this :

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ [OR]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?freepgs.com/pinkness(/.*)?$ [NC]
RewriteRule \.(gif|jpg|png)$ / [F,L]


Both examples were originally provided, but the first one seems to be buggy. The second one works :

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^(http://(www\.)?freepgs.com/pinkness(/.*)?)?$ [NC]
RewriteRule \.(gif|jpg|png)$ / [F,L]

infinity

Hiya webzone

You are FANTASTIC!!!!! It works like a charm, thank you.

webzone (archived)


infinity

Hiya

Although this is working when I tested it yesterday I never checked my site until now. I had to remove the htaccess because its not allowing the images to load on the site.

It was originally in the main directory so I tried placing it in the same folder as the images but they still would not load. Any suggestions.

Thanks

webzone (archived)

#13
which code are you using? i realize that there might be something wrong with the first one (i should check this out), but the second one should work as expected. as a reminder, here is the second code :

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^(http://(www\.)?freepgs.com/pinkness(/.*)?)?$ [NC]
RewriteRule \.(gif|jpg|png)$ / [F,L]

infinity

Hiya

I just tried the second code and images still can be hotlinked.
The first code prevented hotlinking but also prevented images from showing up on the site.