Apache2忽略了htaccess文件

时间:2018-05-18 15:17:34

标签: .htaccess apache2

我基本上想将所有www重定向到http。

在我的/etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ServerName www.rentauto-sofia.com
        ServerAlias rentauto-sofia.com

        ProxyPass / http://rentauto-sofia.com:8000/
        ProxyPassReverse / http://rentauto-sofia.com:8000/
        DocumentRoot /var/www
        <Directory / >
        </Directory>
</VirtualHost>
<Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

我的.htaccess文件如下所示:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

我曾尝试将垃圾放入.htaccess file,但apache忽略了它。我启用了a2enmod expiressudo a2enmod rewrite

编辑:

文件.htaccess位于/var/www/html/

0 个答案:

没有答案