S
S
Shing2020-01-29 20:09:59
htaccess
Shing, 2020-01-29 20:09:59

One htaccess on domain and sub.domain, both 301 on https. How to make www on domain without touching sub.domain?

WP Multisite. Both domain & sub.domain work on https
But domain must be set to www.domain
Without affecting sub.domain

How to do it? Now like this:

RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-01-29
@dodo512

RewriteEngine On

RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?>www\.|)(domain\.com)$ [NC]
RewriteRule ^(.*)$ https://www.%1/$1 [R=301,L]


RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?>www\.|)(.+\.domain\.com)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question