M
M
Maxim Gerasimenko2018-11-25 23:04:04
htaccess
Maxim Gerasimenko, 2018-11-25 23:04:04

Is the 301 redirect set up correctly on the site?

On the site https://24medcentr.com/ , it was necessary to set up a 301 redirect from http to https, and from www to without www.
Those. any request should redirect to https://24medcentr.com/
The hoster claims that everything is set up correctly.
But when I check the redirect, I get this picture:
5bfaff246550e179602104.png

i.e. the redirect from www.24medcentr.com goes to https://www.24medcentr.com , but it needs to go to https://24medcentr.com/

But when you open www.24medcentr.com , https://24medcentr opens in the browser . com/

Is this normal? Or the 301 redirect is not configured correctly.

I need it for Google. So that the snippet contains the site address without www. And in the site settings in the Google Search Console, I can’t select a domain without www, because this function is not available.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2018-11-26
@VELIK505

But after all, https://www.24medcentr.com/ still redirects to https://24medcentr.com/
You have everything set up correctly!

S
solascriptura, 2018-11-26
@solascriptura

You now have the following situation:
And it should be like this:
Although, most likely this is not critical, honestly I don’t know, but you can configure it.
If you have Apache, in .htacess it is done like this:

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

RewriteCond %{SERVER_PORT} !^443
RewriteRule (.*) https://24medcentr.com/$1 [R=301,L]

V
Viktor Taran, 2018-11-26
@shambler81

############################################################################
#### Выбор основного зеркала (с www или без www)                        ####
############################################################################
    # 1. Удалить www
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
############################################################################
#### Перенаправляем протокол https на http                              ####
############################################################################
RewriteCond %{HTTPS} on
   # Проверяем наличие https в URL.
RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
   # Перенаправляем протокол на http.

However, keep in mind a couple of BUT
1. browsers do not like to switch to http after visiting https, although the server response code will be the correct browser will still persistently show https and work with it.
Therefore, check the server response and not the browser itself, the browser itself is on your mind
2 .https might not redirect for two more reasons.
There is no https to this site on the server, and the specifics of working with https means FIRST to get the keys, and only then look at the http referer.
And consequently there are no keys - no referer -> no site -> no .haccess -> no redirect;)
well, the most trump option
there is one site with http and the other http + https in this case, there is a possibility that the first site will send the content of the neighboring site to https. Unfortunately, this happens quite often, and here again the problem of getting the referee after half the keys and nothing else, up to the fact that the site does not have https at all, but he finds out about it only after he connects through it.
well, to the undergrowth, in 2018 redirecting to http is not even funny ;(
Everyone switched to https a long time ago

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question