[英]How to Create .htaccess rewrite rule ignoring authentication requests
我正在使用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>
我嘗試了以下.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>
有沒有一種方法可以創建.htaccess重寫條件以跳過身份驗證請求?
這是一個可行的解決方案,但我不知道為什么。 我在index.php文件的開頭添加了以下內容。
<?php
if (substr($_SERVER['REQUEST_URI'],0,4) == '/svn') {
die();
}
if (substr($_SERVER['REQUEST_URI'],0,5) == '/trac') {
die();
}
?>
如果有人知道為什么這樣有效,我很想知道!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.