How to block a url using .htaccess?

Member

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

How to block a url using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dedrick , 4 months ago

@mac 

To block a specific URL using .htaccess, you can use the following directive:


RewriteEngine OnRewriteRule ^url-to-block/ - [F,L]


Replace url-to-block with the URL you want to block. This rule will return a 403 Forbidden error whenever someone tries to access that specific URL.


Make sure to place this code in the .htaccess file in the root directory of your website. Additionally, ensure that the mod_rewrite module is enabled on your server for this directive to work.