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

Member

by dana , in category: Third Party Scripts , 9 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 , 9 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.

Related Threads:

How to block folder access to ftp with .htaccess?
How to block access to one page and redirect to another?
How to show random products on home page in shopify?
How to block website from loading in iframe?
How to block unwanted hosts in .htaccess?
How to block a specific image using .htaccess?