Forum Moderators: phranque

Message Too Old, No Replies

htaccess hotlink help

php screws me over...

         

darkwarlord

6:17 am on Aug 23, 2007 (gmt 0)

10+ Year Member



Hello all, I had a problem getting my hotlink thing to work googling other sites, and only somebody here posted something that worked for me. I can't reply since its old, lol.

this is my current setup and it works flawless on regular .ext's

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://example.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.example.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://ds.example.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://xg.example.org/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://xchan.example.org/.*$ [NC]
RewriteCond %{REQUEST_URI} !/images/theft\.jpg$
RewriteRule \.(gif¦png¦jpg)$ http://www.example.org/images/theft.jpg [NC,R=302,L]

but when I add php into (gif¦png¦jpg), my site goes dead. LOL.
since I use portal/ phpbb.

My problem is...why i'm posting, since I have installed a mod which allows a gallery is there some way I add php, like maybe album.php to be blocked? the images are incased into it, via

http://example.org/site/modules/mx_smartor/album.php?smartor_mode=album_pic&pic_id=3

I uploaded an example on my friends host off my own domain, of what i'm trying to block.
http://ds.bad-guy.com/aas/in122dex.html
just copying the url, the album thing above, people can link it still. it's what i'm trying to block, but adding (gif¦php¦png¦jpg) kills the site.

[edited by: jdMorgan at 1:18 pm (utc) on Aug. 23, 2007]
[edit reason] No URLs, please. See TOS. [/edit]

jdMorgan

1:31 pm on Aug 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to move the URL-path check from the rule into a RewriteCond, and then check for requests for image files [OR] the URL and query string used to invoke the image-display function of your script:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.(gif¦png¦jpg)$ [NC,OR]
RewriteCond %{REQUEST_URI}>%{QUERY_STRING} /album\.php>smartor_mode=album_pic&pic_id=
RewriteCond %{HTTP_REFERER} !^http://([^.]+\.)?example\.org [NC]
RewriteCond %{REQUEST_URI} !/images/theft\.jpg$
RewriteRule \. http://www.example.org/images/theft.jpg [R=302,L]

I cleaned up several other errors and efficiency problems, probably left over from the original auto-generated code.

Replace the broken pipe "¦" characters with solid pipes before use; Posting on this forum changes the pipe characters.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

darkwarlord

8:40 am on Aug 31, 2007 (gmt 0)

10+ Year Member



oh no urls? my bad. I figured you'd need em for me to help describe it a bit better. late reply, since a lot of stuff happened this week. I just tried out the code for the

RewriteCond %{REQUEST_URI}>%{QUERY_STRING} /album\.php>smartor_mode=album_pic&pic_id=

didn't work. i was still able to leech the original file from my host, at my friends site.

jdMorgan

1:46 pm on Aug 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you flush your browser cache between tests?

If an image is cached in the browser, it will be rendered from the cache, and no request will be sent to your server. If no request is sent to the server, then no code on the server can affect the page display.

Jim