I want to redirect my website to https://subdomain.domain.com
in my .htaccess file.
Redirects:
http://subdomain.domain.com => https://subdomain.domain.com
http://www.subdomain.domain.com => https://subdomain.domain.com
https://www.subdomain.domain.com => https://subdomain.domain.com
https://subdomain.domain.com => no redirects
This should do it…
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
First rule redirect all www to https://subdomain.domain.com , second all http to https://subdomain.domain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule (.*) https://subdomain.domain.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://subdomain.domain.com/$1 [R=301,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.