Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .htaccess for hotlinking

    Hi Folks,

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

    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:
    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:
    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)

  • #2
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So, I'm guessing by no responses, that the code is correct, and the problem lies elsewhere?

  • #3
    New Coder
    Join Date
    Mar 2010
    Posts
    27
    Thanks
    0
    Thanked 1 Time in 1 Post
    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

  • #4
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •