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.

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

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏