【问题标题】:How to Create .htaccess rewrite rule ignoring authentication requests如何创建忽略身份验证请求的 .htaccess 重写规则
【发布时间】:2013-12-26 11:13:06
【问题描述】:

我正在使用 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 重写条件以跳过身份验证请求?

【问题讨论】:

    标签: php apache .htaccess mod-rewrite trac


    【解决方案1】:

    这是一个有效的解决方案,但我不知道为什么。我在 index.php 文件的开头添加了以下内容。

    <?php
    
    if (substr($_SERVER['REQUEST_URI'],0,4) == '/svn') {
        die();
    }
    
    if (substr($_SERVER['REQUEST_URI'],0,5) == '/trac') {
        die();
    }
    
    ?>
    

    如果有人知道为什么会这样,我很想知道!

    【讨论】:

      猜你喜欢
      • 2011-01-23
      • 2011-06-14
      • 1970-01-01
      • 1970-01-01
      • 2019-03-13
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      • 2017-04-29
      相关资源
      最近更新 更多