I have 2 domains hosted on the same account but I want to restrict the second one to not access files.
I have abc123.com and zyx987.com.
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 abc123.com.
The download folder has files like: file1.pdf or file2.zip.
I tried the 'deny from all' but this didnt work since the other domain is blocked too.
Is there another way?
htaccess IP deny access. To deny access to a block of IP addresses, simply omit the last octet from the IP address: deny from 123.456. 789.
htaccess, IP deny rules must be created. These rules can be configured to block all users or specific users (based on their IP address) from accessing website resources. You can also use . htaccess to block a domain, deny access to certain file types, specific files (for example, configuration files), and more.
Here's what you have to do. Put this in your .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?zyx987.com$
RewriteRule ^download - [F]
This will block any request like:
/download/
/download/file1.jpg
/download/another/file.zip
and give a permission denied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With