[英]How to Create .htaccess rewrite rule ignoring authentication requests
I am running cpanel with apache 2.2.25 and have the following site custom configuration setup 我正在使用Apache 2.2.25运行cpanel,并具有以下站点自定义配置设置
WSGIScriptAlias /trac /usr/share/trac/cgi-bin/trac.wsgi
<Directory /usr/share/trac>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
<Location "/trac/login">
AuthType Basic
AuthName "Trac"
AuthUserFile /home/[user]/public_svn/conf/htpasswd
Require valid-user
</Location>
I have tried the following .htaccess
configuration, and others, but the authentication prompt is not displaying when I go to www.mydomain.com/trac/login
, instead it is redirecting to index.php
. 我尝试了以下.htaccess
配置以及其他配置,但是当我转到www.mydomain.com/trac/login
,身份验证提示未显示,而是重定向到index.php
。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^svn - [L,NC]
RewriteRule ^trac - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Is there a way to create .htaccess rewrite condition to skip authentication requests? 有没有一种方法可以创建.htaccess重写条件以跳过身份验证请求?
This is a solution that works, but I don't know why. 这是一个可行的解决方案,但我不知道为什么。 I added the following to the beginning of the index.php file. 我在index.php文件的开头添加了以下内容。
<?php
if (substr($_SERVER['REQUEST_URI'],0,4) == '/svn') {
die();
}
if (substr($_SERVER['REQUEST_URI'],0,5) == '/trac') {
die();
}
?>
If anyone knows why this works I'd love to know! 如果有人知道为什么这样有效,我很想知道!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.