自定义身份validation页面 – Apache mod_auth_form – 错误405方法不允许

我有麻烦试图让Apache的mod auth_form工作。

我有一个子域,我希望保护和使用我的网站上的各种pipe理function。

当我提交auth表单时,我得到:

Method Not Allowed The requested method GET is not allowed for the URL /admin/index.html. 

我已经按照我的最佳能力在这个文档中的说明:

http://httpd.apache.org/docs/current/mod/mod_auth_form.html

和这里:

http://httpd.apache.org/docs/current/mod/mod_session.html

我也使用Apache 2.4.9,所有需要的模块为此工作加载。

所以我已经build立了子域如下:

 /index.html (Public root / auth form) /admin/index.html (The contents of the folder i wish to protect) 

/index.html包含以下内容:

 <form method="POST" action="/admin"> User: <input type="text" name="httpd_username" value="" /> Pass: <input type="password" name="httpd_password" value="" /> <input type="submit" name="login" value="Login" /> </form> 

对于控制子域的Vhost块,我已经添加了以下内容(注意,我为这个域启用GET和POST,因为默认情况下这些被禁用):

 <VirtualHost *:80> ServerAdmin [email protected] ServerName mydomain.com ServerAlias admin.mydomain.com DocumentRoot /var/www/mydomain.com/admin/ <Directory /var/www/mydomain.com/admin/> <LimitExcept GET POST> Require all denied </LimitExcept> Options -ExecCGI -FollowSymLinks -Includes -Indexes -MultiViews Require all granted </Directory> <Location /admin> SetHandler form-login-handler AuthFormLoginRequiredLocation http://admin.mydomain.com/index.html AuthFormLoginSuccessLocation http://admin.mydomain.com/admin/index.html AuthFormProvider file AuthUserFile /var/www/mydomain.com/admin_inc/.htpasswd AuthType form AuthName realm Session On SessionCookieName session path=/private;domain=admin.mydomain.com;httponly;secure; SessionCryptoPassphrase secret </Location> </VirtualHost> 

在Apache错误日志中,我得到以下内容:

 [Mon May 19 10:26:38.xxxxxx 2014] [auth_form:error] [pid xxxxx] [client xxxxxx:xxxxx] AH01811: the form-login-handler only supports the POST method for /admin/index.html, referer: http://admin.mydomain.com/ 

如果有人能向我解释我在这里做错了什么,为了创build这个错误,将不胜感激,谢谢!

您以某种方式发送login凭据与某些不是POST 1的方法。 也许仔细检查你的login表单?

¹http : //code.ohloh.net/file?fid=Pwx9mfavxhieWn8XSiBldWz63zI&cid=h1J7pf7LYjw&s=&fp=305270&mp&projSelected=true# L1127