Restrict access to your Apache Virtual Host

In some case you need to restrict your virtual host site by IP address. Usually the type of site that handle important information such as Administrator site or web-based database administration site (eg : phpMyAdmin) or else. For example the admin site of your website can be accessed only in Office network. This Apache configuration below may helps you.

<VirtualHost *:80>
    DocumentRoot /path/to/website/admin

    <Location />
          Order Deny,Allow
          Deny from all
          Allow from


The IP address above is your public IP address of your office. Beside <Location>, you also can use the other Apache directive <Directory>.

You can see the complete documentation of configuration sections containers in Apache, that may be suits your need. Here is the link

Yup. That’s all.

Leave a Reply

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