# htaccess and login



## KoosHopeloos (Nov 3, 2004)

L.S., 

For a fairly simple website I require some sort of login from the index page.

I have a log-in and password form box on the index page. When that is filled in (with the right log-in and password) I would like it to redirect to the index2 in a subfolder.

The log-in and password will be fixed.

I really would like to keep it simple and I understood that this can be done with .htaccess and .htpasswd. I've tried a couple of things, but for some reasons it doesn't work.

I'm completely new with this, guidence would be much appreciated!

Regards, Koos


----------



## Fjandr (Sep 26, 2012)

This is a fairly concise tutorial on creating a user and password for .htaccess:

Password protection with htaccess

As for the redirection, you can either use PHP to redirect once the page is loaded, or possibly use an .htaccess redirect (though I don't know if that will redirect before or after the login, or if the file needs to be specially constructed to make sure it takes place after). You'll also need to protect the pages that you're redirecting to, in order to make sure only the authenticated user can view them.


----------



## KoosHopeloos (Nov 3, 2004)

Thanks Fjandr, worked like a charm.

In the end, I've added a log-in link to index2, which is inside the protected folder. Now, you can log-in 'normally'. 

And as the pages are within the protected folder, you can not view these.

Regards, Koos


----------



## Fjandr (Sep 26, 2012)

Good deal, glad you got it working.


----------

