有人能帮助解决以下问题吗:
我正在尝试对所有不匹配的域进行重写并将它们推送到给定文件夹。以下虚拟主机在本地运行(带有 XAMPP 的 Mac OS X),但在 Debian 服务器上不起作用:
<VirtualHost *:80>
UseCanonicalName On
ServerName www.domain.de
ServerAlias *
DocumentRoot "/var/www/www.domain.de/current/web"
DirectoryIndex index.php
Alias /sf /var/www/www.domain.de/current/lib/vendor/symfony/data/web/sf
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
SetEnv SYMFONY_ENVIROMENT prod
<Directory />
Options +Includes
Options +FollowSymlinks
Options -Indexes
AllowOverride All
AuthType Basic
AuthName "Info"
AuthUserFile /var/www/www.domain.de/current/.htpasswd
Require valid-user
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteLog "/var/www/www.domain.de/current/log/rewrite.log"
RewriteLogLevel 3
# Rewrites to host folder if not a main/my domain
RewriteCond %{HTTP_HOST} !^(www\.)?domain.de|(www\.)?my-domain.(de|net|at|ch|eu|com)$
RewriteRule ^(.*)$ /var/www/www.domain.de/current/websites/aliases/%{HTTP_HOST}/$1 [L]
</IfModule>
答案1
在 Debian 上,mod_rewrite 默认是禁用的。因此请尝试启用它,然后重新启动 apache
启用 mod_rewrite
a2enmod rewrite
然后重启apache
/etc/init.d/apache2 restart
然后尝试规则