How can i restrict a user from accessing a certen path?

June 18, 2016 1.4k views
MySQL Apache PHP Security

Dear all,
I have a droplet with Ubuntu 14.04.3 x64 installed on it.
If i have a web site (web-app php over mysql) like:
I want to forbid all users (except a certin IP address) from accessing:
How can i do that?

2 Answers

If you are using Apache as your webserver in a default configuration then you most likely have mod_rewrite enabled.

In that case you can create a file “.htaccess” in the directory you want to protect.


Order Allow,Deny
Allow from

Then simply replace with the the IP address that you want to allow through and it will only allow requests from that IP address.

On Apache 2.4, the syntax is:

Require ip
Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!