How to block access to the home page of the website in .htaccess?

Member

by dana , in category: Third Party Scripts , 3 months ago

How to block access to the home page of the website in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by mallory_cormier , 3 months ago

@dana 

To block access to the home page of a website using .htaccess, you can use the following code:

1
2
3
4
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^$ - [F]
</IfModule>


This code uses mod_rewrite to block access to the root directory of your website (i.e. the home page). It will return a 403 Forbidden error when someone tries to access the home page.


Simply add this code to your .htaccess file in the root directory of your website. It will block access to the home page while still allowing access to other pages on the website.