How to Deny Access to Specific URL in htaccess?

By Hardik Savani November 5, 2023 Category : .htaccess

Hello,

This tutorial will provide example of how to deny access to specific url in htaccess. In this article, we will implement a htaccess deny access to specific url. you'll learn htaccess deny access to specific path. This post will give you simple example of htaccess block access to specific url.

If you need to block some specific url for all then you can do it using .htaccess file, i will give you following examples, how to do that.

let's see following solution.

Example 1:

you can not access "your_website/test.html" directory.

.htaccess

RewriteEngine On

RewriteRule ^test.html$ - [F]

Example 2:

you can not access "your_website/data/test.php" directory.

.htaccess

RewriteEngine On

RewriteRule ^data/test.php$ - [F]

you can see layout as bellow:

i hope it can help you...

Tags :
Shares