L
L
Loner19952020-01-23 09:39:33
Apache HTTP Server
Loner1995, 2020-01-23 09:39:33

How can I amend the rule so that it applies to 3rd level domains?

There is a rule for redirecting from http and www to https without www, but it doesn't work for 3rd level domains, and I don't know how to add it correctly.
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule (.*) https://%1/$1 [R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-01-23
@shambler81

RewriteCond %{HTTP_HOST} ^www\.(.+)\.(.+)$
RewriteRule (.*) https://%1/$1 [R=301,L]
this will be for only the third level
You can even try to merge
RewriteCond %{HTTP_HOST} ^www(\.(.+)){1,2}$
RewriteRule (.*) https://%1/$1 [R=301,L]
But judging by the regular expression, it should have been there anyway work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question