![](/img/trans.png)
[英]Rewrite conditions and rules in Virtual host or .htaccess? Which is preferred?
[英]Apache rewrite rules inside a virtual host
将重写规则从.htaccess
迁移到VirtualHost
遇到一些麻烦。
当我在VirtualHost
外部的Directory下使用它时,它可以工作,但是出现一些身份验证错误-所以我想知道我应该对其进行更改以使其在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>
提前致谢。
解决我身份验证问题的原因是添加
Order allow,deny
Allow from all
到现有的<Directory /var/www/server/subfolder/>
。
尽管在<VirtualHost>
之外具有<Directory>
时,我仍然只能设法使其工作。
谢谢大家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.