简体   繁体   中英

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

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 .

<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?

This is a solution that works, but I don't know why. I added the following to the beginning of the index.php file.

<?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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM