Welcome Guest, Not a member yet? Register   Sign In
How to restrict IP on folder of controllers from apache config?
#1

[eluser]gwerner[/eluser]
I'd like to restrict access to a folder of controllers that are used for admin purposes only. I've tried a number of ways and not coming up with a solution. These controllers are behind password protection. But, I'd like to just remove it from view if someone happens to stumble upon the right directory. Can this be done? I'd rather not do it from htaccess. I have access to the apache config files, so I'd like to handle it there.

Does it have anything to do with the way Codeigniter routes? Or, am I just way off?

This what I'm using that doesn't work
Code:
<Directory /var/www/application/controllers/folder/>
Order deny,allow
Deny from all
</Directory>
#2

[eluser]gwerner[/eluser]
This is something I've found while searching the googlenet. This doesn't seem to be the best option. But the only path I've discovered that may work. Thoughts?

Code:
$your_ip_address='123.123.123.123'; //change it to yours
if (!isset($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $your_ip_address)) {
   exit();
}
#3

[eluser]CroNiX[/eluser]
If you want to restrict access to a dir by IP via apache, you just need to add an additional line(s) after your "Deny from all", like:
Order Deny,Allow [this says, first I'll tell you to do deny, then I'll tell you who to allow]
Deny from All [You are denying everybody]
Allow from 123.123.123.123 [except this IP]
Allow from 234.234.243.234 [and this IP]
#4

[eluser]gwerner[/eluser]
I tried that, but I wasn't having any success. The example I put in first is what I had whittled it down to try to get anything to work. This is my original original that I was tried that doesn't work.

Code:
<Directory /var/www/application/controllers/foldertoblock/>
            Order deny,allow
            Deny from all
            Allow from xxx.xxx.xxx.xxx
            Allow from xxx.xxx.xxx.xxx
</Directory>

If I just try to block the web root this worked.

Code:
<Directory /var/www/>
            Order deny,allow
            Deny from all
            Allow from xxx.xxx.xxx.xxx
            Allow from xxx.xxx.xxx.xxx
</Directory>

Does it not work because the Codeigniter handles everything through the index.php?




Theme © iAndrew 2016 - Forum software by © MyBB