M
M
mod1332018-04-16 18:13:47
Search Engine Optimization
mod133, 2018-04-16 18:13:47

Redirect, www / https mirrors what is the procedure?

Hello? dear! I'm trying to deal with redirects and everything is mixed up from a large amount of different information. Please help me structure.
There is a site (landingPage) with the names www.example.ru and example.ru
, an SSL certificate is installed on the domain, so it turns out there is also:
www.example.ru and example.ru
httpS://www.example.ru and httpS://example .ru
A slash at the end of the name, I read somewhere, I also understood this as it is considered a mirror.
Task: how to give the user https://example.ru in search results?
In the Google panel, I indicated example.ru
for Yandex, as I understand it, you need to specify the host
, you can still make changes to .htaccess and everything went mess ((
I would be very grateful if you explain

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2018-04-17
@shambler81

RewriteEngine On
   #  Директива включает редиректы.
RewriteBase / 
   # Без директивы (.*) = /$1 будет /var/wwww/site/web/$1  с директивой  = /$1
Options +FollowSymLinks
   # Разрешает переход по символическим ссылкам.
php_flag display_errors off
  # запретить отображение ошибок  
php_flag allow_url_fopen off
  # запретить  использовать удаленые файлы 

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

I
Ilya Oblomov, 2018-04-17
@Oblomow

The question is asked in a strange way, but I will try to answer.
You need to open the .htaccess file (did you find where it is located?)
In it, one by one, prescribe the rules and change their order, if necessary.
I would write in the following order:
Examples:

RewriteEngine On
RewriteBase /
# https
RewriteEngine On
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# www.site.ru -> site.ru
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# + /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]

When adding each rule, check that it is executed.
The rules themselves will most likely have to be googled, since I even remember about 3-4 options for switching to https, some of which may not work for you.
Well, change the order if when you connect one, the other turns off.
Now I answer the last question:
Register Yandex.Webmaster and Google Search Console.
In Yandex.Webmaster, specify the desired address (that is, with https, if I understand your desire correctly) and confirm the rights to it.
Or use the "Move site" button if you are already using Webmaster.
In the moving column, you can add / remove https and www.
Changes will not happen immediately, be prepared to wait.
In Google Search Console, add the desired display option.
If you want with https, add with https.
After adding the required version from both panels, do not forget to go through the rest of the settings, specify the path to sitemap.xml if you plan to add other pages.
This is for the issue of issuance, but it will not work until you do the redirects.
If you have done everything (redirects are configured and working, new sites with https have been added in the webmaster), and the site is still without https in the search results, then wait and check what the webmaster writes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question