Reputation: 35
I have an apache 2.4 server which is hosting 2 applications. One of which is freely accessible to the internet and the other is restricted to certain IPs. So within my /etc/apache2.conf file I have the following:
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/other/>
Options FollowSymLinks
AllowOverride None
Require ip [ip]
</Directory>
This works fine and I get a 403 forbidden when trying to access any page being served from /var/other unless im on the right IP. However, I would now like to make certain pages within the /var/other/ directory freely accessible without the IP restriction. I have tried various combinations such as the following which has a nested <Files> tag to grant all access to a specific file but doesnt seem to work.
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/other/>
Options FollowSymLinks
AllowOverride None
Require ip [ip]
<Files "/var/other/page.php">
Require all granted
</Files>
</Directory>
Ive tried putting the <Files> tag before the "Require ip [ip]" as well as before and after the <Directory> tag but also dont seem to work. Does anyone know if this is possible and how I would go about implementing it?
Upvotes: 1
Views: 4074
Reputation: 17872
You should not have the directory, just the filename, in the Files section:
<Files "page.php">
Upvotes: 1