1. Переадресация с добавлением / в конце
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)(?<!/)$ /$1/ [R=301,L]
2. Переадресация с домена с WWW на домен без WWW
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
3. Переадресация с домена без WWW на домен с WWW
#RewriteCond %{HTTP_HOST} ^([^www].*)$
#RewriteRule ^(.*)$ http://www.%1/$1 [L,R=301]
4. Переадресация с index.php на / , кроме отправки форм, иначе бывает ломаются некоторые
RewriteCond %{REQUEST_FILENAME} ^(.*)/index\.php$
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^(.*)index\.php(.*)$ /$1$2 [R=301,L]
5. Варианты перенаправления на httpS, необходимо выбрать один подходящий
# 1.
RewriteCond %{HTTPS} =off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
# 2.
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# 3.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 4.
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Ниже приведен код стандартного конфигурационного файла .htaccess для Битрикс с внесенными правками от seo специалистов.
Options -Indexes
ErrorDocument 404 /404.php
<IfModule mod_php5.c>
php_flag session.use_trans_sid off
#php_value display_errors 1
#php_value mbstring.internal_encoding UTF-8
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Переадресация с добавлением / в конце
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)(?<!/)$ /$1/ [R=301,L]
# Переадресация с домена с WWW на домен без WWW
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Переадресация с домена без WWW на домен с WWW
#RewriteCond %{HTTP_HOST} ^([^www].*)$
#RewriteRule ^(.*)$ http://www.%1/$1 [L,R=301]
# Переадресация с index.php на / , кроме отправки форм, иначе бывает ломаются некоторые
RewriteCond %{REQUEST_FILENAME} ^(.*)/index\.php$
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^(.*)index\.php(.*)$ /$1$2 [R=301,L]
# Варианты перенаправления на httpS, выберите подходящий
# 1.
#RewriteCond %{HTTPS} =off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
# 2.
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# 3.
#RewriteCond %{HTTPS} off
#RewriteCond %{HTTP:X-Forwarded-Proto} !https
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 4.
#RewriteCond %{ENV:HTTPS} !on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"
ExpiresByType image/png "access plus 3 day"
ExpiresByType text/css "access plus 3 day"
ExpiresByType application/javascript "access plus 3 day"
</IfModule>
Надеюсь, эта статья помогла вам разобраться в фишках от сеошников для .htaccess