How to disallow access to a subdomain using .htaccess?

Member

by rollin , in category: Third Party Scripts , a month ago

How to disallow access to a subdomain using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , a month 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.