1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice

How do I prevent hotlinking in Plesk?

Discussion in 'Plesk for Linux - 8.x and Older' started by CBiLL, Feb 1, 2005.

  1. CBiLL

    CBiLL Guest

    0
     
    I tried several different rewrites in htaccess and they all are giving me a Internal server error when enabled ..

    How do I prevent hotlinking using htaccess in Plesk?

    Thanks
    Bill
     
  2. CBiLL

    CBiLL Guest

    0
     
    Welp .. I got hotlink block to work but it only stops the cgi scripts on the server from working ... ie forums or redirect etc etc and if I disable the hotlink block in htaccess it cgi script start working again ..

    So what is Plesk doing that I need to get around to it to allow cgi script and hotlink block on my server?

    Bill
     
  3. CBiLL

    CBiLL Guest

    0
     
    Update .. I already added Addhandler and tried +ExecCGI in the htaccess and then put the hotlink rewrite back in but it still breaks the cgi scripts on my servers ..

    Look like Plesk doesn't allow you to have rewrite and cgi scripts together ..

    Also I took out the cgi redirect script and tried using htaccess redirect and then put the rewrite in it and it also broke htaccess redirect as well too ..

    Something wrong with rewrite mod in Plesk it look like ..

    Bill
     
  4. CBiLL

    CBiLL Guest

    0
     
    Got it working without breaking the cgi scripts on the server ..

    Had to add the rewrites in the domain's httpd.conf ..putting it in htaccess works but just breaks the any cgi scripts you have installed on your server..

    Oh well I guess that's Plesk

    Bill
     
  5. pdreissen

    pdreissen Guest

    0
     
    Great conversation,

    If you liked to post the solution then anybody with the same problem can be pointed in the right direction, or can use your solution!

    Regards,

    Pascal!
     
  6. CBiLL

    CBiLL Guest

    0
     
    You use the same code for rewrite that you normally use in .htaccess but since putting it in htaccess in Plesk breaks any cgi script or redirects you have running on the server or in htaccess so then you will need to edit the domain's own httpd conf which is normally located in

    /home/httpd/vhosts/yourdomain.com)/conf/httpd.include

    and add this between the <VirtualHost your_server_ip:80> and </VirtualHost>

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com(/)?.*$ [NC]
    RewriteRule .*\.(gif|jpe?g|png|bmp)$ [F,NC]

    You change "yourdomain.com" to the actual domainname you are trying to add hotlink preventation on.

    And also you can add more of those per line

    RewriteCond %{HTTP_REFERER} !^http://(www\.)?otherdomain.com(/)?.*$ [NC]



    For each domain outside of your domain to allow them to hotlink your images so if you have people using your banner on thier site you need to add them to the RewriteCond. Change otherdomain.com to the actual domain you want to allow hotlinking to your server images ..

    Restart httpd and you should be set ..

    Bill
     
  7. Jason Lee

    Jason Lee Guest

    0
     
    If you put anything in httpd.include it will be overwriten by Plesk. you should look at using the vhost.conf or vhost_ssl.conf which will not be overwriten by Plesk.
     
  8. CBiLL

    CBiLL Guest

    0
     
    I already tried vhost.conf and it won't work at all ..

    unless I am missing something ..

    So far Plesk have not overwritten my httpd.include as of yet but when it does which I am sure it does at every upgrade .. Ill just put it back in there ..

    Could you share how you would edit them in vhost.conf to enable hotlinking protection?

    Bill
     
  9. Jason Lee

    Jason Lee Guest

    0
     
    I'm not sure if it is possible but you could try putting your Rewrite directives between <directory /path/to/the/directory> and </directory>

    As if you change any settings in the domain it will rewrite the httpd.conf file for the domain.
     
  10. CBiLL

    CBiLL Guest

    0
     
    Did that .. didn't work either ..

    Bill
     
  11. Whistler

    Whistler Guest

    0
     
    Remember when you create a vhost.conf for a (sub-)domain, you always need to run:

    [path_to_your_psa]/admin/bin/websrvmng --vhost-name=<the host you've just changed>

    To make Plesk register your vhost.conf file in the httpd.include setup.

    And then restart Apache.
     
  12. wenowo

    wenowo Guest

    0
     
    Hi,
    wrote all the RewriteEngine stuff I had (and that was working on a other server without plesk) in the htaccess file in the vhost.conf

    Executed websrvmng and tried to restart apache.

    Apache stopps but does not restart, telling me the command "RewriteEngine" is not known.

    If I try by putting directly "RewriteCond..." it is telling me, "unknown command RewriteCond.."

    Anybody has a hint?
     
  13. Whistler

    Whistler Guest

    0
     
    You could start by including the configuration failing... include the section you've written in vhost.conf....
     
  14. wenowo

    wenowo Guest

    0
     
    OK, here what I have now in vhost.conf

    "
    DirectoryIndex index.htm index.html index.php

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mywebsitesurl(/)?.*$
    [NC]
    RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://mymainsite.com [R,NC]
    "

    But I don't think the problem lies here, because this worked well on my other server without plesk, by including that in my htaccess file.
     
Loading...