How to disallow access to a subdomain using .htaccess?

Member

by rollin , in category: Third Party Scripts , 4 months ago

How to disallow access to a subdomain using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , 4 months ago

@rollin 

To disallow access to a subdomain using .htaccess, you can add the following lines to the .htaccess file located in the root directory of the subdomain:

1
2
3
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.example.com [NC]
RewriteRule ^ - [F]


Replace "subdomain.example.com" with the actual subdomain that you want to disallow access to. This code snippet uses mod_rewrite to block access to any URL within the specified subdomain. When someone tries to access the subdomain, they will receive a 403 Forbidden error.