drfu29983 2014-12-11 22:49
浏览 26
已采纳

htaccess用html格式

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.

  • 写回答

1条回答

  • douhan8009 2014-12-11 22:56
    关注

    .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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多