Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-05-2010, 06:59 PM   PM User | #1
NW Dave
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
NW Dave is an unknown quantity at this point
.htaccess for hotlinking

Hi Folks,

Added this .htaccess file to root to block hotlinking as per here: http://www.javascriptkit.com/howto/htaccess10.shtml

Quote:
RewriteBase /images
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?pitman.us/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.pitman.us/images/angryman.jpg [R,L]
I added the first line of code as per instructions from server owner. (see below)
I placed the file in the root, and in the folder "images". Doesn't seem to work.
Can someone please point out where I went off the tracks?

Thank you,
Dave

My question to host:
Quote:
Hi,
I wanted to set an .htaccess file to stop hotlinking. It is dependant on the the server having 'mod rewrite' enabled.
Is it so?
Their Reply:
Quote:
Hello,

We use virtual user directory paths, so you can get error when trying to setup search engine friendly URLs or trying to pass virtual directory names to PHP scripts. If can be fixed very easy. Edit your .htaccess file and add this line at the top of the file or before the first rewrite rule:

RewriteBase /

Note: if your script is installed on some directory, for example /forum, you have to place RewriteBase /forum line to the .htaccess file (.htaccess file must be also located in /forum directory)
NW Dave is offline   Reply With Quote
Old 04-06-2010, 07:58 PM   PM User | #2
NW Dave
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
NW Dave is an unknown quantity at this point
So, I'm guessing by no responses, that the code is correct, and the problem lies elsewhere?
NW Dave is offline   Reply With Quote
Old 04-07-2010, 02:46 AM   PM User | #3
gameutopia
New Coder

 
Join Date: Mar 2010
Posts: 27
Thanks: 0
Thanked 1 Time in 1 Post
gameutopia is an unknown quantity at this point
If your domain is pitman . us

I believe the response you received regarding RewriteBase would be more like
RewriteBase /
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?pitman.us/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.pitman.us/images/angryman.jpg [R,L]

Then if you placed this in the location pitman.us/.htaccess

It would be in the main directory / folder of pitman . us so any folders/subfolders such as /images are covered by this .htaccess. The subfolders / directories obey the top level .htaccess unless you add a custom one in a particular folder to over-ride it.

I can't say for sure about the rest of the code right off hand, just the RewriteBase / part.
__________________
dolphin tutorials and Resources
gameutopia is offline   Reply With Quote
Old 04-07-2010, 05:16 PM   PM User | #4
NW Dave
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
NW Dave is an unknown quantity at this point
Gameutopia, thanks for your reply;

I originally tried the code exactly as you have it, with no success, and simply added the images to Rewrite Base / as an attempt to have it work.

I can still link directly to an image file within the folder /images, so for some reason, the server is not parsing the .htaccess file, or I'm not understanding it's true function.
NW Dave is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:49 AM.


Advertisement
Log in to turn off these ads.