ItSolutionStuff.com

How to Deny Access to Specific URL in htaccess?

By Hardik Savani • November 5, 2023
.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...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Whitelist/Allow IP Address using .htaccess File?

Read Now →

How to Restrict/Block IP Address using .htaccess File?

Read Now →

How to Clone Laravel Project from Github on Server?

Read Now →

How to Generate and Add SSH Key in Github?

Read Now →

How to Generate SSH Key in Ubuntu Server?

Read Now →

How to Check Apache Access & Error Log Files in Ubuntu Server?

Read Now →

How to Whitelist/Allow IP Address in Apache Ubuntu?

Read Now →

How to Restrict/Block IP Address in Apache Ubuntu?

Read Now →

How to Set Up Password Authentication with Apache in Ubuntu?

Read Now →