A
A
Azami2019-03-16 20:00:43
htaccess
Azami, 2019-03-16 20:00:43

How to organize a 301 redirect from http://www to https://?

Hello, we have moved to the https protocol.
Used by ISPManager 5
In the domain settings in isp, the item "Redirect HTTP requests to HTTPS" is checked.
http is redirected to https without problems.
But here's how to set up a redirect from http: //www directly to https:// without www?
The fact is that if you specify in .htaccess

# Rewrite www
RewriteCond %{HTTP_HOST} ^www.site.ru$
RewriteRule (.*) https://site.ru/$1 [R=301,L]

then when accessing www.site.ru, the following chain is obtained:
www.site.ru -> [301] https://www.site.ru -> [301] https://site.ru
Tell me how to exclude from the chain https://www.site.ru, so that when accessing www.site.ru, a redirect is carried out immediately to https://site.ru?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SubGANs, 2019-03-22
@SubGANs

Make a separate virtual host config in Apache for www and immediately redirect from it to without www with https. So it will be easier and clearer than fencing rules in htaccess.
In Spanish, this can be done in the config tab in www-domains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question