Aussie Bloggers Forum
Welcome,
Guest
. Please
login
or
register
.
March 17, 2010, 03:06:29 pm
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Visit the Aussie Bloggers Blog
Search:
Advanced search
45953
Posts in
3789
Topics by
1206
Members Latest Member:
-
Ben-123
Most online today:
11
- most online ever:
275
(December 30, 2007, 07:51:23 pm)
Forum Rules
Forum Rules
Recent Posts
Why Did I Buy That...
by
California Girl
[October 06, 2009, 10:10:11 am]
My Passion...
by
California Girl
[October 06, 2009, 10:05:49 am]
Blog competitions
by
benny
[October 06, 2009, 04:00:34 am]
how do I stop this?
by
CrystalsQuest
[October 04, 2009, 03:32:49 am]
How can I make a pdf file...
by
SnakyPoet
[October 01, 2009, 07:15:38 am]
Very Cool Software for se...
by
squadron
[September 29, 2009, 03:55:23 pm]
Yum Cha - Favs?
by
Tamsyn
[September 29, 2009, 03:54:31 pm]
Favourite Ice-Cream
by
Tamsyn
[September 29, 2009, 03:53:26 pm]
Themes
Helios_Multi TP
oxygen11final
Stats
Members
Total Members: 1206
Latest:
Ben-123
Stats
Total Posts: 45953
Total Topics: 3789
Online Today: 11
Online Ever: 275
(December 30, 2007, 07:51:23 pm)
Users Online
Users: 0
Guests: 16
Total: 16
Visit the Aussie Bloggers Blog
Aussie Bloggers Forum
Forum
Archive
Blogging in General
Preventing people viewing images directly
Pages: [
1
]
« previous
next »
Author
Topic: Preventing people viewing images directly (Read 2213 times)
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Preventing people viewing images directly
«
on:
February 20, 2008, 02:50:57 pm »
I'm using wordpress and I'm wondering how I can stop people accessing my uploads folder (and its contents) directly. I was looking at my analytics and noticed a large number of people viewing an image in my uploads folder directly (must have got stumbled). How can I block that and/or redirect people requesting files from my uploads folder to my homepage?
eg. Currently people can view images directly by typing in a url like this:
http://www.url.com/uploads/08/image.jpg
When anyone does that, I want them to be redirected to
http://www.url.com
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
amyjoanna
Fair Dinkum
Posts: 34
Re: Preventing people viewing images directly
«
Reply #1 on:
February 20, 2008, 04:20:52 pm »
I have the same problem too - for some reason people keep googling for a certain nineteenth century painting of Queen Elizabeth I and an image I've used previously is the number one search result in google images.
As far as stopping the initial problem of people linking to and visiting your image rather than your website, I have no idea - I'd be interested to see what advice everyone else has too!
Logged
MY NEW BLOG -
Desirable.co.uk
- All the best finds in fashion, homewares, gadgets and accessories.
MY PERSONAL BLOG -
AmyJoanna.co.uk
- travelling the world, one irrelevant post at a time.
Lani
Emeritus Erro
Legend
Posts: leet
I am just testing this...
Re: Preventing people viewing images directly
«
Reply #2 on:
February 20, 2008, 05:56:34 pm »
They could be finding the images via an image search. Perhaps it is possible to change the folder permissions so that doesn't happen? But I don't really understand folder permissions.
Logged
Knitting For Afghanistan ~
The WinterWarm Project
~ Knitting Can Save Lives
Blogging Personal
~
The Cerebral Mum
~
Plato's Sandbox
"The diary is an art form just as much as the novel or the play. The diary simply requires a greater canvas."
~ Henry Miller
admin
Administrator
Havin' A Squiz
Posts: 14
Re: Preventing people viewing images directly
«
Reply #3 on:
February 20, 2008, 06:27:37 pm »
Hrm, this is something I should have done before but never occurred to actually find a way.
Well after a quick search I find a couple of possible answers..
From
an apache tutorial
I got an example using the good old .htaccess file:
Quote
Here’s how I do it. First, we slap that regex down on the incoming HTTP request to gauge whether it’s a hotlinked image.
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !underscorebleach\.net [NC]
RewriteCond %{HTTP_REFERER} !bloglines\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /view_image.shtml?/$1 [R,NC,L]
Lines 2 through 6 allow hotlinking from my site, Bloglines, Google, and cached items. I also allow requests with a null HTTP_REFERER value to obtain the image; this occurs in the case of bookmarks, some proxies, some browser settings, some third-party privacy plugins, etc. If you try to get tricky and force users to have a referrer from your own domain, you’re likely to get yourself in trouble. Trust me.
The last line redirects users to an SHTML page. Notice that I pass the value of the REQUEST_URI as a parameter in the URL to view_image.shtml. In the source, I then use a simple SSI directive to output the image. Here is the source of view_image.shtml. (file has .txt extension but put it on your website as .shtml) [updated 9/14/05 for clarity]
A quick note about this redirection technique: You do need to actually redirect, that is, use the “R” flag on the RewriteRule. If you don’t, you’re going to feed the browser an HTML page when it’s expecting an image, and it’s liable to get confuzzled.
And voila! Now, when users link to your images, they get the image, but they also get an unavoidable little advertising pitch from you, the webmaster and payer of bandwidth bills.
There's a note in there that out-right denial can cause issues with some clients esp in the case if they're using a proxy etc.
Also from a reference manual there's also
this one
, but it's more for people with direct access to Apache config files.
As far as a simpler "all files in this dir need a referrer" well it's on that track but I'll see if I (or anyone else?) can refine it better.
Edit: In case you missed the first tutorial reffered to in the first link I gave,
read on it here
, possibly more relevant to what we're looking for here.
Quote
Here’s my anti-hotlinking .htaccess instructions:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?dorkytutorial\.com [NC]
RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]
Lines 2 and 3 establish the conditions for blocking an image from being rewritten. Line 2 says, to block client loading of the image, “the referrer must be not null.” Line 3 says, to block client loading of the image, “the referrer must not come from any domain of dorkytutorial.com”—and the “NC” part makes that check not case sensitive.
Line 4 checks that the filetype is a GIF, JPEG, JPG, or PNG, and if so, sends an HTTP 403 response of FORBIDDEN to the client (that’s the “F” part on the end). Also, the “L” flag means that this is the last rule to process, so that if an HTTP request matches this rule, don’t bother stepping through any further rewrite rules in the .htaccess. This one is mostly for effiency’s sake.
«
Last Edit: February 20, 2008, 06:39:56 pm by admin
»
Logged
--
"Always enjoying life as never knowing how long it will last."
kathiemt
Riotous Chook
Legend
Posts: 1533
Re: Preventing people viewing images directly
«
Reply #4 on:
February 20, 2008, 08:12:18 pm »
Can't you just upload a blank index.htm to the uploads folder or set up a redirection order in cpanel for that folder?
Logged
Kathie M. Thomas
Author, Blogger, Virtual Assistant
http://www.soho-life.com
- Life in a small office
http://muchaboutmelbourne.com/
- Much About Melbourne
http://kathiesphotos.com/
- Kathie's Photos
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #5 on:
February 20, 2008, 09:10:26 pm »
Quote from: kathiemt on February 20, 2008, 08:12:18 pm
Can't you just upload a blank index.htm to the uploads folder or set up a redirection order in cpanel for that folder?
I've tried the blank index.html and it didn't seem to work. Would you need to put it in each of the sub folders of the uploads folder? For example, wordpress creates a new folder under uploads each month.
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
Snoskred
Drive It Like You Stole It
Emeritus Erro
Legend
Posts: 2408
Bonfires In My Head
Re: Preventing people viewing images directly
«
Reply #6 on:
February 20, 2008, 09:13:08 pm »
That's optional, the monthly new folder thing. You can change it if you wanted to by ticking a box in the miscellaneous screen..
In fact none of the blogs I host should be using monthly folders because it causes issues with folder permissions.
Logged
~ Snoskred - Life In The Country ~
~ Snoskred provides
Wordpress Blog Hosting
~
~ Check out my big shiny
RSS Subscribe Icons
- free for all to download! ~
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #7 on:
February 21, 2008, 07:38:31 am »
Quote from: Snoskred on February 20, 2008, 09:13:08 pm
That's optional, the monthly new folder thing. You can change it if you wanted to by ticking a box in the miscellaneous screen..
In fact none of the blogs I host should be using monthly folders because it causes issues with folder permissions.
There you go, learn something new every day. If i ticked that box now would it screw things up?
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
Snoskred
Drive It Like You Stole It
Emeritus Erro
Legend
Posts: 2408
Bonfires In My Head
Re: Preventing people viewing images directly
«
Reply #8 on:
February 21, 2008, 12:12:27 pm »
No, not as long as you leave all the images where they currently are.
I think it will start putting images in the main folder area as soon as you untick it, might be best to try it and make sure.
Logged
~ Snoskred - Life In The Country ~
~ Snoskred provides
Wordpress Blog Hosting
~
~ Check out my big shiny
RSS Subscribe Icons
- free for all to download! ~
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #9 on:
February 22, 2008, 09:03:20 am »
Quote from: Snoskred on February 21, 2008, 12:12:27 pm
No, not as long as you leave all the images where they currently are.
I think it will start putting images in the main folder area as soon as you untick it, might be best to try it and make sure.
I might trial that on one of my old crappy wordpress blogs first.
So rather than a blank html index file, could I use that file to redirect to the homepage?
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
Snoskred
Drive It Like You Stole It
Emeritus Erro
Legend
Posts: 2408
Bonfires In My Head
Re: Preventing people viewing images directly
«
Reply #10 on:
February 22, 2008, 09:04:46 am »
Possibly.
Note I am no expert on this like the Admin is.
Logged
~ Snoskred - Life In The Country ~
~ Snoskred provides
Wordpress Blog Hosting
~
~ Check out my big shiny
RSS Subscribe Icons
- free for all to download! ~
MarkSBurgunder
Riotous Chook
True Blue
Posts: 99
Driving my Lamborghini
Re: Preventing people viewing images directly
«
Reply #11 on:
February 22, 2008, 12:19:31 pm »
If your blog is hosted on a server with cPanel, than have a look in the Security Section for "Hotlink Protection". That should let you set this type of redirection up without to many hassles.
Regards
Mark
Logged
Strawbale House
- Building Progress of Our Strawbale House
---
Avanti Hosting
- No Worries Web Hosting
www.avantihosting.com.au
email:
sales@avantihosting.com.au
phone: (07) 3129 0115
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #12 on:
February 22, 2008, 04:23:12 pm »
Quote from: MarkSBurgunder on February 22, 2008, 12:19:31 pm
If your blog is hosted on a server with cPanel, than have a look in the Security Section for "Hotlink Protection". That should let you set this type of redirection up without to many hassles.
Regards
Mark
Ive handled hotlink protection by editing my htaccess file. When I use the cpanel i end up getting 403 errors for some reason.
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
MarkSBurgunder
Riotous Chook
True Blue
Posts: 99
Driving my Lamborghini
Re: Preventing people viewing images directly
«
Reply #13 on:
February 23, 2008, 09:02:37 am »
Quote from: swollenpickles on February 22, 2008, 04:23:12 pm
When I use the cpanel i end up getting 403 errors for some reason.
Hmm.. I just tried it on one of my own sites using cPanel and it worked without any problem.
I suggest you let your hosting provider know as they may have a misconfiguration somewhere.
You never know this might also stop you form using other features of cPanel in the future when you need them.
Logged
Strawbale House
- Building Progress of Our Strawbale House
---
Avanti Hosting
- No Worries Web Hosting
www.avantihosting.com.au
email:
sales@avantihosting.com.au
phone: (07) 3129 0115
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #14 on:
February 23, 2008, 11:10:31 am »
I've placed blank "index.htm" files in the relevant folders and its still possible to access the images directly. Here's what my htaccess file looks like. Any more ideas?
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#here the www rule
RewriteCond %{HTTP_HOST} !^www\.swollenpickles\.com$ [NC]
RewriteRule ^(.*)$ http://www.swollenpickles.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?swollenpickles\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
Lani
Emeritus Erro
Legend
Posts: leet
I am just testing this...
Re: Preventing people viewing images directly
«
Reply #15 on:
February 23, 2008, 03:15:53 pm »
No ideas from me.
touching the htaccess file freaks me out.
Logged
Knitting For Afghanistan ~
The WinterWarm Project
~ Knitting Can Save Lives
Blogging Personal
~
The Cerebral Mum
~
Plato's Sandbox
"The diary is an art form just as much as the novel or the play. The diary simply requires a greater canvas."
~ Henry Miller
Anonymum
A woman of excess
Administrator
Legend
Posts: 1482
I may be getting older, but I refuse to grow up
Re: Preventing people viewing images directly
«
Reply #16 on:
February 23, 2008, 03:56:13 pm »
Just looking at that file makes me break out in a sweat, so I'm not much good either I'm afraid...
Logged
The Nook of Oz
MarkSBurgunder
Riotous Chook
True Blue
Posts: 99
Driving my Lamborghini
Re: Preventing people viewing images directly
«
Reply #17 on:
February 24, 2008, 05:22:24 am »
Following is what cPanel has put into the .htaccess file where I have set-up Hotlink Protection:
Code:
RewriteCond %{HTTP_REFERER} !^http://3blacketst.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://3blacketst.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.3blacketst.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.3blacketst.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|JPG|JPEG|GIF|PNG|BMP)$ http://3blacketst.com [R,NC]
This actually redirects a browser to the homepage is someone is going straight to an image file.
URL for an image to try if you want:
http://3blacketst.com/IMG_0903.JPG
PS: That house is actually for sale...
Logged
Strawbale House
- Building Progress of Our Strawbale House
---
Avanti Hosting
- No Worries Web Hosting
www.avantihosting.com.au
email:
sales@avantihosting.com.au
phone: (07) 3129 0115
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #18 on:
February 24, 2008, 08:45:33 pm »
Quote from: MarkSBurgunder on February 24, 2008, 05:22:24 am
Following is what cPanel has put into the .htaccess file where I have set-up Hotlink Protection:
Code:
RewriteCond %{HTTP_REFERER} !^http://3blacketst.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://3blacketst.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.3blacketst.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.3blacketst.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|JPG|JPEG|GIF|PNG|BMP)$ http://3blacketst.com [R,NC]
Thanks Mark. I've given that code a go, so in theory, clicking this image should redirect to my homepage;
http://www.swollenpickles.com/wp-content/uploads/2007/11/logono1.jpg
so this is what i have now:
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#here the www rule
RewriteCond %{HTTP_HOST} !^www\.swollenpickles\.com$ [NC]
RewriteRule ^(.*)$ http://www.swollenpickles.com/$1 [R=301,L]
RewriteCond %{HTTP_REFERER} !^http://swollenpickles.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://swollenpickles.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.swollenpickles.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.swollenpickles.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|JPG|JPEG|GIF|PNG|BMP)$ http://www.swollenpickles.com [R,NC]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
MarkSBurgunder
Riotous Chook
True Blue
Posts: 99
Driving my Lamborghini
Re: Preventing people viewing images directly
«
Reply #19 on:
February 25, 2008, 09:06:21 am »
Hmm... That should work ...
Do you know what version of Apache is used by your web host?
Logged
Strawbale House
- Building Progress of Our Strawbale House
---
Avanti Hosting
- No Worries Web Hosting
www.avantihosting.com.au
email:
sales@avantihosting.com.au
phone: (07) 3129 0115
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #20 on:
February 25, 2008, 09:10:59 am »
Quote from: MarkSBurgunder on February 25, 2008, 09:06:21 am
Hmm... That should work ...
Do you know what version of Apache is used by your web host?
Not sure to be honest. I'm with Hostgator right now.
So if you click this link what do you see?
http://www.swollenpickles.com/wp-content/uploads/2007/11/logono1.jpg
edit: this is bizarre, the image above no longer appears in the post. I'm buggered if I know what's happening. See if this logo displays.
http://www.swollenpickles.com/wp-content/uploads/2007/11/logono2.jpg
«
Last Edit: February 25, 2008, 09:13:07 am by swollenpickles
»
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
swollenpickles
Tall Poppy
Posts: 464
I'm special.
Re: Preventing people viewing images directly
«
Reply #21 on:
February 26, 2008, 07:33:10 am »
Ok, had a disaster last night. Enabled hotlink protection via cpanel, and all my sites went to crap at the same time (they are hosted as "add on domains"). Not pretty. Long story short, I've gone back to what I had originally (thankfully I backed up everything on my server at the end of Jan).
Logged
extreme blogging
>
recording
>
comics
>
guitar effects
>
car news
Pages: [
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Announcements
-----------------------------
=> Forum Guidelines
===> Forum & Blog News
===> Forum How To Guides
===> Technical Glitches
-----------------------------
Coffee Lounge
-----------------------------
=> Introduce Yourself
=> Kaos And Mayhem
-----------------------------
Technical Assistance & Blogging Discussion
-----------------------------
=> Blogging In General
=> Pimp Your Blog
=> Wordpress
=> Google Blogger & Blogspot
=> Other Blog Platforms
=> Social Media
=> Tools & Resources
=> Blog Post Suggestions and Requests
-----------------------------
Thorny Blog Issues
-----------------------------
=> Ways To Promote Your Blog
=> Ways To Monetize Your Blog
-----------------------------
Archive
-----------------------------
=> Tools and Resources
=> Ways to Promote Your Blog
=> Introduce Yourself
=> Blogging in General
=> Kaos and Mayhem
=> Wordpress
=> Forum Archive
Show unread posts since last visit
Visit the Lazy Bloggers Post Generator
- Our present to you.
Happy Birthday To Aussie Bloggers Forums!
Visit the Lazy Journalists Plane Story Generator
- Another present to you.
Enjoy!