Results 1 to 11 of 11
  1. #1

    block access with htaccess

    Hello,

    I need to block a folder with images with a prohibition that shouldn't be accessed from the web.

    The images should be accessed from only one domain.

    Is possible to do this task through htaccess?

    Suggestion will be appreciated!

    Regards

  2. #2
    Please,

    I need to block a specific folder setting the .htaccess inside allowing two subdomains to see the images inside the folder, and block all others.

    <FilesMatch "\.(jpg|jpeg|png)$">
    Allow from subdomain1.domain.com
    Allow from subdomain2.domain.com
    Deny from all
    </FilesMatch>
    Tryied with the following code but doesn't work.

    Any help?

  3. #3
    A bit confused, are you trying to restrict your images being used by other websites? Are you referring to hotlink protection? If yes, then you can do it from cpanel, if you are using cpanel as your control panel. If you have wordpress, then it has a hotlink protection plugin as well. Not sure if I understood your requirement clearly.

    Also have you mentioned "Order Allow,Deny " anywhere in htaccess?
    Freelance Server Administrator
    Email : divineprad@gmail.com
    Skype : divineprad
    http://greproot.com

  4. #4
    Hello Francogas,

    Can you please confirm if the server running with nginx reverse proxy? If you just need the external domains not to use the images of the site for their use, you just need to enable hotlink protection from cPanel (If the server is cPanel).

  5. #5
    As tech-home mentioned, If you are using cPanel you can activate Hotlink protection from the control panel for those directories.
    documentation.cpanel.net/display/ALD/Hotlink+Protection

    and If you are not using cPanel, it is also possible to do it via htaccess by adding the following code:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourwebsite.com/.*$ [NC]
    RewriteRule \.(jpg|jpeg|gif|png|bmp)$ - [F]
    Just replace HTTP_REFERER with your site url and add the .htaccess file in the directory in which you want the hotlink protection.

  6. #6
    The domain name which you want to access your images is from same server or from different server.

    If it is resolving from a different Ip address, you can apply simply .htacess rules to access the images folder only from a specific Ip address like

    Order Deny,Allow
    allow from XXX.XXX.XXX.XXX
    deny from all

  7. #7
    Hi,

    This can easily be done using .htaccess codes. You can deny the access of the images directly from all and allow it from one IP of the subdomain you want.

    <FilesMatch "\.(jpg|gif|png)$">
    order deny,allow
    deny from all
    allow from <subdomain_IP>
    </FilesMatch>
    www.24x7servermanagement.com
    Server Management, Server Security, Server Monitoring.
    India's Leading Managed Service Provider !! Skype: techs24x7

  8. #8
    Hi

    I'm referring to hotlink protection, but If I use cPanel it put the htaccess in the root of my site, and I need to put the htaccess in the specific folder.

  9. #9
    Quote Originally Posted by DivinePrad View Post
    A bit confused, are you trying to restrict your images being used by other websites? Are you referring to hotlink protection? If yes, then you can do it from cpanel, if you are using cpanel as your control panel. If you have wordpress, then it has a hotlink protection plugin as well. Not sure if I understood your requirement clearly.

    Also have you mentioned "Order Allow,Deny " anywhere in htaccess?
    Hi

    I'm referring to hotlink protection, but If I use cPanel it put the htaccess in the root of my site, and I need to put the htaccess in the specific folder.

  10. #10
    Quote Originally Posted by BlessHost View Post
    As tech-home mentioned, If you are using cPanel you can activate Hotlink protection from the control panel for those directories.
    documentation.cpanel.net/display/ALD/Hotlink+Protection

    and If you are not using cPanel, it is also possible to do it via htaccess by adding the following code:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourwebsite.com/.*$ [NC]
    RewriteRule \.(jpg|jpeg|gif|png|bmp)$ - [F]
    Just replace HTTP_REFERER with your site url and add the .htaccess file in the directory in which you want the hotlink protection.
    Hi, this is the correct htaccess, but I need to allow an external domain with a lot of subdomains.

  11. #11
    Join Date
    Jan 2012
    Posts
    527
    If you use Apache 2.4 (and not 2.2) then you can easily do something like:

    Code:
    <RequireAll>
    Require host mydomain.com another.domain.com
    </RequireAll>
    The above block can be added within a <File> or other directive. You may also restrict by IP address with: Require ip 0.0.0.0

Similar Threads

  1. Can I block referrers with .htaccess?
    By dtang in forum Programming Discussion
    Replies: 2
    Last Post: 08-18-2006, 07:58 PM
  2. Block a Webpage with .htaccess
    By ariful in forum Web Design and Content
    Replies: 9
    Last Post: 06-28-2006, 07:10 AM
  3. Restricing access to one IP with .htaccess problems
    By lux_interior in forum Hosting Security and Technology
    Replies: 2
    Last Post: 09-14-2005, 12:03 PM
  4. Limiting access with .htaccess
    By MicroFX in forum Hosting Security and Technology
    Replies: 1
    Last Post: 06-11-2002, 07:17 PM
  5. Block IP with .htaccess?
    By filburt1 in forum Hosting Security and Technology
    Replies: 2
    Last Post: 03-07-2002, 09:02 PM

Tags for this Thread

Posting Permissions

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