Welcome Guest, Not a member yet? Register   Sign In
Password Protecting App in Development
#1

[eluser]vinoth15[/eluser]
Hello,

I am developing a web application using CI at www.thisapp.com (example
domain). My CI install is located outside the www root folder.

How do I go about password protecting my application while still allowing
my "home page" (in this case the default controller/view in CI ) to be
publically accessible ?

I.E. I want to develop my application without any authorized users (i.e.
the public) poking around, but still want a landing page to be visible.

I've been able to use .htaccess to password protect my entire www root, is
there anyway to exclude the home page from protection ? And if so, what
file would I exclude in my CI setup ?

Thanks again. I hope that makes sense.
#2

[eluser]Buso[/eluser]
If you have a base controller, you can make a simple check inside its constructor like:

Code:
if( $this->uri->uri_string()!='/' AND ! is_role('admin')) {
  redirect();
}

Of course you will need to create the is_role function or something similar, and authenticate through a login panel or something. You could also make an IP check, and if it is different to yours, redirect to the home.

Code:
$my_ip = 'your.ip.goes.here';
if( $this->uri->uri_string()!='/' AND ! $this->input->ip_address()!=$my_ip) {
  redirect();
}

Or set a cookie with a secret value




Theme © iAndrew 2016 - Forum software by © MyBB