我下面有以下vhost,我的目标是:
我仍然无法配置我的虚拟主机删除www并强制网址(使用301)到没有www的网址
<VirtualHost *:80>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /usr/local/ssl/api_site_com.crt
SSLCertificateKeyFile /usr/local/ssl/myserver.key
SSLCACertificateFile /usr/local/ssl/api.site.com.cer
ServerName api.site.com
ServerAlias www.api.site.com
DocumentRoot "/var/www/api.site.com/public"
<Directory "/var/www/api.site.com/public">
Options Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
有人可以帮助我吗?
答案 0 :(得分:0)
我使用这两行删除'www':
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteRule ^/(.*) http://example.com/$1 [R=301,L]