[英]Apache rewrite rules inside a virtual host
I'm having some trouble with migrating my rewrite rules from .htaccess
to a VirtualHost
. 将重写规则从
.htaccess
迁移到VirtualHost
遇到一些麻烦。
When I'm using below Directory outside the VirtualHost
it works, but I get some authentication errors - so I'm wondering to what I should change it to make it work inside the VirtualHost
. 当我在
VirtualHost
外部的Directory下使用它时,它可以工作,但是出现一些身份验证错误-所以我想知道我应该对其进行更改以使其在VirtualHost
工作。
Or should they be added to <Directory /var/www/server/>
还是应该将它们添加到
<Directory /var/www/server/>
Rules: 规则:
<Directory /var/www/server/subfolder/>
RewriteEngine On
RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)
RewriteRule ^(.*)$ /subfolder/index.php/$1 [L]
</Directory>
VirtualHost: 虚拟主机:
<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>
Thanks in advance. 提前致谢。
What fixed the authentication issue for me was to add 解决我身份验证问题的原因是添加
Order allow,deny
Allow from all
to the existing <Directory /var/www/server/subfolder/>
. 到现有的
<Directory /var/www/server/subfolder/>
。
Though I still only managed to get it to work when having <Directory>
outside of <VirtualHost>
. 尽管在
<VirtualHost>
之外具有<Directory>
时,我仍然只能设法使其工作。
Thanks all. 谢谢大家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.