我基本上想将所有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 expires
和sudo a2enmod rewrite
文件.htaccess
位于/var/www/html/
。