CodeIgniter and htaccess - Protect a specific controller and its methods via AuthType? |
[eluser]k00k[/eluser]
I asked this on stackoverflow but didn't get any response. I have an admin controller which has some methods that I want to protect. http://blabla.com/admin/ http://blabla.com/admin/edit_coupon/ http://blabla.com/admin/edit_photo/ I don't need a full blown authentication system for this site, so I'd prefer to just utilize htaccess and AuthType for any /admin/ URLs. My current .htaccess is a basic CI one. Code: RewriteEngine on How do I do this? Just to be thorough: I know how to use htaccess and htpasswd. My question is how to protect a controller which is not really a directory. I tried using the Location directive with no success.
[eluser]k00k[/eluser]
I got this to work by following this post: http://ellislab.com/forums/viewthread/141775/
[eluser]monaye[/eluser]
How did you handle on url? if default rout is to show "welcome" http://myapplication.com/ => "welcome" http://myapplication.com/admin/ => "welcome"
[eluser]k00k[/eluser]
[quote author="monaye" date="1302076760"]How did you handle on url? if default rout is to show "welcome" http://myapplication.com/ => "welcome" http://myapplication.com/admin/ => "welcome"[/quote] I'm not sure what you're asking, please try to be a bit more descriptive in your question. My default route is to a controller called 'home': $route['default_controller'] = "home"; However, this has no effect on the fact that I can visit http://myapplication.com/admin/ and be prompted by htaccess for password. Like I said, I just followed that other post (creating real folder named 'admin', copying the CI index.php and setting up .htaccess/.htpasswd) and it worked fine. |
Welcome Guest, Not a member yet? Register Sign In |