Apache重写虚拟主机内的规则

时间:2013-01-04 10:01:17

标签: apache mod-rewrite apache2

我将重写规则从.htaccess迁移到VirtualHost时遇到了一些问题。

当我在VirtualHost以外的目录下使用它时,我会收到一些身份验证错误 - 所以我想知道应该更改它以使其在VirtualHost内工作。

或者是否应将其添加到<Directory /var/www/server/>

规则:

<Directory /var/www/server/subfolder/>
    RewriteEngine On
    RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)
    RewriteRule ^(.*)$ /subfolder/index.php/$1 [L]
</Directory>

虚拟主机:

<VirtualHost *:80>
ServerAdmin admin@server.com
Servername server.com
ServerAlias server2 server2.com server server.com

DocumentRoot /var/www/server

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory /var/www/server/>
    AuthType NTLM
    AuthName Server
    require valid-user

    PythonAuthenHandler pyntlm
    PythonOption Domain SERVER.COM
    PythonOption PDC xxx.xxx.xxx.xxx
    PythonOption BDC xxx.xxx.xxx.xxx

    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/server.com_error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/server.com_access.log combined env=!nolog
</VirtualHost>

提前致谢。

1 个答案:

答案 0 :(得分:0)

修复身份验证问题的原因是添加

Order allow,deny
Allow from all

到现有的<Directory /var/www/server/subfolder/>

虽然在<Directory>之外<VirtualHost>时我仍然设法让它工作。

谢谢大家。