Monday, June 4, 2012

Using .htaccess to restrict access to files

I have 2 domains hosted on the same account but I want to restrict the second one to not access files.

I have and

In my php I do everything I need to display the domain name and template based on the domain but I want only the /download files to be accessed from

The download folder has files like: file1.pdf or

I tried the 'deny from all' but this didnt work since the other domain is blocked too.

Is there another way?

Source: Tips4all

1 comment:

  1. Here's what you have to do. Put this in your .htaccess

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(www.)?$
    RewriteRule ^download - [F]

    This will block any request like:


    and give a permission denied.