user1097772
user1097772

Reputation: 3529

htaccess with html form

Is possible to use .httaccess to some place on the server via html form?
Suppose we can use php, html, javascript, .httaccess
I will explain it.
For example I will have www.myserver.com/administration/
In folder administration will be some filestructure for administrator and only authorized users shoul be able to access it.

One option is use simple .htaccess rule and you will need to access thought that ugly grey popup which consist of login and password.

Second option is use standard session notification in php - form in html send it via post, proccess it in php script, if you have right login and pass, create session and then check session on each page you need login for.
Third option - why don't mix it a bit. I don't know if its possible so this is my question: Let's have same html form we would use for login via php with sessions, we will send it by post method somehow to athentication mechanism which is behind the htaccess authentification, than if it pass redirect to admin folder www.myserver.com/administration/
suppose that login form is on www.myserver.com/login.php

additional demands: 1)if I'm not logged in - redirect to loggin.php or better show some error page with message so send to the error page some information via post for example set $_POST["message"] = "not logged"
2)be able to loggout - so assign logout action to some button html link ...
3)if its possible to folder is it possible set it only for specific filles on server or for some filestructure I'll define? for example login rule will be necessary for this 2 folders(all pages in it) and this 3 php pages which are somewhere else for exaple in third folder which will have protected only that 3 files and other will be accessible for everyone.
4)if this option is even possible is possible have more than one group of users? I suppose that htaccess authentification works just like you can pass and you can't pass.

Hope somebody find the time to read this and answer it. My question is if its even possible do it this way I described.

Upvotes: 1

Views: 1539

Answers (1)

Quentin
Quentin

Reputation: 943510

.htaccess is just a way of configuring Apache.


One option is use simple .htaccess rule and you will need to access thought that ugly grey popup which consist of login and password.

There are various standard authentication mechanisms built into HTTP that Apache supports and which you can configure through a .htaccess file.


Let's have same html form we would use for login via php with sessions, we will send it by post method somehow to athentication mechanism which is behind the htaccess authentification,

You can write an Apache module that uses a form to handle the initial login process. This would typically be done with Perl or C. An example of one is Apache::AuthCookie.

You can then use .htaccess to configure Apache to use the module for various URLs on your site.

Upvotes: 2

Related Questions