我的.htaccess文件适用于任何需要1特定文件夹的罚款。 结果, http://www.mydomain.com/administration/index.php //www.mydomain.com/administration/index.php意外地进入401错误页面,而不是从pipe理文件夹加载index.php 。
所以,对于pipe理文件夹,我希望:
1)总是用httpsreplacepipe理文件夹(对于其他文件夹,.htaccess的最后一部分工作正常)。
2)不要redirect的URL,如果他们去pipe理文件夹。
3)1)和2)之后的所有规则对pipe理文件夹无效。
我试图添加2)和3).htaccess。 所以,现在我的.htaccess文件如下所示:
#adds www - always, for any url, for any folder RewriteCond %{HTTP_HOST} !^www.mydomain.com$ RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L] #special rules for administration folder only - set https if not https RewriteCond %{REQUEST_URI} ^/administration RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301] #all requests to administration folder should stop here RewriteCond %{REQUEST_URI} ^/administration RewriteRule ^ - [L] #some rules below - not for administration folder
但是,如果我inputmydomain.com/administration/index.php ,我会希望转到https://www.mydomain.com/administration/index.php 。 其余的工作完美。
如果我删除.htaccess,它直接到任何一个
http://www.mydomain.com/administration/index.php https://www.mydomain.com/administration/index.php
没有问题。
先谢谢你。
401响应意味着Authorization required并提示您的浏览器询问您的用户名和密码。 它们不是由mod_rewrite控制的,而是由一个授权模块控制的 。
您必须在.htaccess文件或主Apacheconfiguration文件中有一些Auth*指令。
我怀疑在重写模块之前触发了授权模块,所以在处理任何重写之前必须拥有有效的用户。
当你提供有效的用户名和密码时,你会得到什么?