Back to Top

How to Protect file using .htaccess

htaccess protect file

htaccess is a very simple and quick solution for restricting access to files or directory structures.In this post, we will learn about the protecting a file on the server using htaccess file.

Sometimes your web site contains sensitive information which you don’t want to share the public or to allow access others.So you can protect so file using htaccess especially when you don’t want anybody to change the content of the file.

In this article, you protect a file so that when a user visits a page using that directory or file which is not allowed to visitors.

Let’s see the syntax of it which clears the usage of directive in htaccess

SYNTAX:

< Files filepath > – It’s a container for directives restricting files match with the specified patterns.

The directive limits the access of the file as per directives in the block to the file which should be a path from documentRoot.

This can be achieved by including following lines of code by adding into the .htaccess file.

Now, let’s see the code which is used to protect the file for a specific user only. After adding the IP address of the user, it will be accessible to the particular user.

Above code will enable access for IP address 127.0.0.1 only.That’s it..!! we’re done with the file protection using htaccess file.Let me know if you have any query /issue for implementing this code.

Stay tuned to creativedev… 😉

Share:
Share on Facebook1

Share on LinkedIn0Tweet about this on TwitterShare on Google+3Buffer this pageDigg thisShare on Reddit0

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular Posts

How to parse the JSON string using jQuery

Posted on 4 years ago

Bhumi

How to Import Users in MODx from CSV file

Posted on 4 years ago

Bhumi

To Swap Database Row in PHP

Posted on 5 years ago

Bhumi

HTML5 Geolocation API with Example

Updated 17 years ago

Bhumi

Overview of Views in MySQL

Updated 17 years ago

Bhumi

What is Closure in JavaScript?

Updated 17 years ago

Bhumi

How to use JavaScript Promise API?

Updated 17 years ago

Bhumi

Type Hinting Callable Functions in PHP

Updated 17 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 1 year ago

Bhumi

The Reader’s Poll – August 2014

Posted on 2 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 2 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 3 years ago

Bhumi