[英]redirect http://www.domain.com to https://domain.com
I have the following apache virtualhost: 我有以下apache虚拟主机:
NameVirtualHost *:443
<VirtualHost *:80>
<Directory /home/www/htdocs/domain.tl/html/>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.tl$ [NC]
RewriteRule ^(.*)$ http://fr.domain.tl/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName domain.tl
ServerAlias www.domain.tl fr.domain.tl en.domain.tl files.domain.tl
DocumentRoot /home/www/htdocs/domain.tl/html/
...
<Directory /home/www/htdocs/domain.tl/html/>
Options -Indexes FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.tl$ [NC]
RewriteRule ^(.*)$ https://fr.domain.tl/$1 [L,R=301]
</Directory>
</VirtualHost>
I would like to redirect the http://www.domain.tl OR http://domain.tl to https://fr.domain.tl 我想将http://www.domain.tl或http://domain.tl重定向到https://fr.domain.tl
Actually with this virtualhost, the redirection http to https is correct but the sub domain do not change 实际上,使用此虚拟主机,http到https的重定向是正确的,但子域不会更改
Try changing these lines: 尝试更改这些行:
RewriteCond %{HTTP_HOST} ^domain.tl$ [NC]
RewriteRule ^(.*)$ http://fr.domain.tl/$1 [L,R=301]
to 至
RewriteCond %{HTTP_HOST} ^(?:www\.)domain.tl$ [NC]
RewriteRule ^(.*)$ https://fr.domain.tl/$1 [L,R=301]
so that it also matches "www.domain.tl" and redirects to https in both your virtual hosts: 这样它也匹配“www.domain.tl”并在两个虚拟主机中重定向到https:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.