How to Deny Access to a File using .htaccess?
Hi,
Now, let's see article of How to deny access to a file in .htaccess. if you have a question about htaccess deny access to file then i will give a simple example with solution. This post will give you simple example of htaccess deny access to file extension. step by step explain htaccess deny access to all files except index.php. Let's get started with apache 2.4 htaccess deny access to file.
Here, i will give you list of examples how to deny access files using .htaccess file. sometime we have list of files that we don't want to access directly from url. you can prevent it by access url using .htaccess file. so let's see example one by one.
Example 1: Deny Access to a Single File using .htaccess
.htaccess
<Files ".env">
Order allow,deny
Deny from all
</Files>
Example 2: Deny Access to a File Extension using .htaccess
.htaccess
<Files ~ "\.php$">
Order allow,deny
Deny from all
</Files>
Example 3: Deny Access to a Folder using .htaccess
.htaccess
<Directory ~ "\app">
Order allow,deny
Deny from all
</Directory>
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Angular 13 HttpClient & Http Services Tutorial Example
- Angular 13 CRUD Application Example Tutorial
- How to Create Basic API in Node JS Express?
- How to Get All Files from Folder in Node JS?
- How to Generate QR Code in Node JS?
- Node JS Send Email with Attachment Example
- Node JS Express Route with Parameters Example
- How to Get Data from Json File in Node JS?
- Laravel 8 Mail | Laravel 8 Send Email Tutorial
- Laravel 8 CRUD Application Tutorial for Beginners
- Codeigniter Remove index.php form URL using htaccess