0

我正在努力做到这一点,无论我的网站如何访问:

所有这些重定向到同一个地方:

后两个http://www...https://mywebsite...都有效,但不是第一个。http://www.//由于某种原因,第一个被重定向到。这是我sites-enabled/000-default的重定向:

<VirtualHost *:80>
    ServerName www.metalmetalland.com
    ServerAlias *.metalmetalland.* metalmetalland.* metalmetalland.com

    RewriteEngine On             
    #redirect all port 80 traffic to 443
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/?(.*) https://www.metalmetalland.com/$1 [L,R]

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel debug
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
4

1 回答 1

1

尝试这个:

RewriteEngine On
#not https
RewriteCond %{HTTPS} off
RewriteRule .* https://www.metalmetalland.com%{REQUEST_URI} [R=301,L]

#https, but not www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
于 2013-07-01T23:15:12.253 回答