Answer the question
In order to leave comments, you need to log in
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
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.
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]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question