Tôi không biết tại sao điều này không thành công. Tôi chỉ muốn chuyển hướng tất cả tên miền đến www.maindomain.com
và cũng http
đến https
, tôi đang thiếu gì?Apache2 chuyển hướng đến một tên miền khác với ssl
# redirect http to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# redirect without www to www
RewriteCond %{http_host} ^maindomain.com [nc]
RewriteRule ^(.*)$ https://www.maindomain.com [r=301,nc]
# redirect another domain to www.maindomain.com
RewriteCond %{HTTPS} off # this i was missing
RewriteCond %{HTTP_HOST} ^(www\.)?anotherdomain.com [NC]
RewriteRule ^(.*)$ https://www.maindomain.com [R=301,L]
http://maindomain.com
đểhttps:/www.maindomain.com/
làm việchttp://anotherdomain.com
-https:/www.maindomain.com/
làm việchttps://anotherdomain.com
-https:/www.maindomain.com/
không
lạ, nhận xét với RewriteCond% {HTTPS} tắt, gợi ý đúng ngay bây giờ, nhưng câu trả lời đã bị xóa, giống như tôi muốn chấp nhận nó, tôi đã bỏ lỡ một RewriteCond thứ 2 trong chuyển hướng thứ 3 –