Report this

What is the reason for this report?

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

Posted on June 18, 2016

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: www.example.com I want to forbid all users (except a certin IP address) from accessing: www.example.com/adminpanel How can i do that?



This textbox defaults to using Markdown to format your answer.

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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

On Apache 2.4, the syntax is:

Require ip 10.10.10.10

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.

/path/to/www/example.com/adminpanel.htaccess

Order Allow,Deny
Allow from 10.10.10.10

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.