I
I
Ivan Ivanov2019-06-29 18:58:44
htaccess
Ivan Ivanov, 2019-06-29 18:58:44

How to make a redirect to a single access point from www to without www, taking into account https?

Hello!

RewriteEngine On
RewriteCond %{HTTPS}_%{HTTP_HOST} ^(?|off_(?:www\.)?(.*)|on_www\.(.*)) [NC]
RewriteRule .* https://%1/$0 [R=301,L]
RewriteRule ^(.*)$ /public/$0

Not strong in the plug, so maybe someone who knows will look, I didn’t stuff anything extra here?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2019-07-03
@shambler81

RewriteCond %{ENV:HTTPS} on
    #Если включен https
RewriteRule .* - [E=SSL:s]
    #То создаем переменную  ssl с текстом s
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
    # Проверяем, содержит ли домен www в начале URL.
RewriteRule ^(.*)$ http%{ENV:SSL}://%1/$1 [R=301,L]
    # Перенаправляем удаляем www

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question