Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On my webserver, some folders (like wp-admin/ wp-login.php...) or websites (dev.company.net) are restricted to my IP addresses.

Home, home ipv6, VPN, office, office IPv6.

<Files wp-login.php>
Order Deny,Allow
Deny from all
allow from 88.222.222.88
allow from 92.92.92.92
allow from 2001:DB8:123:5fcc::/64
allow from 2001:DB8:8ae:e6c4::/64
</Files>

My home and office change regularly and I must go around all my htaccess files to gain access again.

Would you see a way of having it in only one place? I could make a ln -s but these .htaccess files often have other informations inside, since in strategic points.

I have access to apache config as well but this is Mass Virtual Hosting, I don't have any <directory> or <location>

share|improve this question

2 Answers 2

up vote 5 down vote accepted

You could use the Include option to load your access config from a central file.

Another option would be some (dynamic) DNS entry for these IP addresses that you update when they change:

allow from myhost.dynds.org
....
share|improve this answer
    
oh I wonder if I add all the "A" and "AAAA" records in my DNS with all my IP like my-secret-addresses.mydomain.com if it would make it! it would be so convenient! thanks a lot –  chriscatfr Sep 14 '11 at 8:42
    
it didn't make it, as shown in this question this is a PTR resolution I think... sad it would have been awesome –  chriscatfr Sep 14 '11 at 15:57
    
I accept this answer even if it doesn't work in my case: this is a mass virtual host. Which means I have only one conf file for an unlimited number of virtual host ( /var/www/virtualhosts/%1/ ). And %1 is www.mywebsite.com . I think only .htaccess could do it. –  chriscatfr Sep 17 '11 at 16:58

As I said, I accepted @Sven 's answer even if it doesn't work in my case: this is a mass virtual host. Which means I have only one conf file for an unlimited number of virtual host ( /var/www/virtualhosts/%1/ ).

Actually I decided to create a folder /home/websites/access/ where I create symbolic links

ln -s /home/websites/websites01/.htaccess /home/websites/access/htaccess.website01

So when I change I won't be looking all around my harddisk

When the file contain only the IP restriction I have one file and just use a symbolic link to it

ln -s /home/websites/access/htaccess.ip-restrict /home/websites/websites02/.htaccess

and /home/websites/access/htaccess.ip-restrict:

<Files wp-login.php>
  Order Deny,Allow
  Deny from all
  allow from 88.222.222.88
  allow from 92.92.92.92
  allow from 2001:DB8:123:5fcc::/64
  allow from 2001:DB8:8ae:e6c4::/64
</Files>

I hope that I won't forget any website when the next change happen only 6 months later and I dont remember everything.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.