douxiajiao8445 2012-01-29 18:18
浏览 69
已采纳

Htaccess - Http身份验证 - 可以捕获GET并应用身份验证然后重定向? 有例子

I have been toying with http authentication using the .htaccess file in an attempt to better my current cms.

I have found a solution in apache whereas, I use a link in my html somewhere <a href=".test">Test</a>.

I then add this to my .htaccess:

<Files .test>
AuthType Digest
AuthNAme "Restricted Page"
AuthDigestProvider file
AuthUserFile /usr/home/myDomain/includes/htpasswd/admin/.htdigest
Require valid-user
# If user is authenticated then redirect
RewriteEngine on
RewriteCond %{REMOTE_USER} !=""
RewriteRule ^.*$ /test.php? [R]
</Files>

What this does, is when a user clicks on the mentioned hyperlink, the user is then prompted with a login form via http authentication. When they enter the correct credentials, they are redirected to a page in the accessable root called test.php, which in turn includes the cms index that is held out of the web root.

If a user selects a section within the cms, they are prompted to log in again (using the sites default php based log in system) and only users with the correct role assignments may access any specfic section.

Although this is useful, it is not quite what i am trying to accomplish.

What i have thought of, is two possible solutions in my case.

One would be where a user could enter say http://www.myDomain.com/?whateveryoulike in the address and be directed to my cms instead. Ideally this redirection would direct straight to my cms index in its' root directory that is not accessable via http://. Something like this which can be done in php:

if isset($_GET['whateveryoulike']) 
{
include $_SERVER['DOCUMENT_ROOT'] . '/../../admin/blah.php';
}

Another option i thought of would be something i do not know very much about, but it relates to http authentication and i have seen in use once before...

Basically the user enters username@www.myDomain.com and they get prompted with the http auth log in box. When the credentials are met, they are sent to a seperate section within the website.

Would anyone be able to provide any input, suggestions or addittional ideas relating to how i would go about this?

My question though, is if it is possible to actually catch a GET (http://www.myDomain.com/?whateveryoulike) apply http authentication then redirect the user to a page that is held out of the http:// root?

Thank you for taking the time to read through this!

  • 写回答

1条回答 默认 最新

  • dongpin4611 2012-01-29 18:29
    关注

    it is possible to actually catch a GET, apply http authentication then redirect the user to a page that is held out of the http:// root?

    No.
    The reason is possible fraud, which was used some years ago.
    Since then browsers refuse to authorize users silently.

    I see no point in the whole enterprize at all, though.

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

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP