M
M
mydarck2019-11-12 11:59:40
Apache HTTP Server
mydarck, 2019-11-12 11:59:40

How to remove double/triple redirect?

Hello! The task came from an SEO specialist: It is necessary to replace double and triple 301 redirects from pages without “/” at the end with single 301 redirects to pages with “/” at the end.
I understand this double / triple redirect because first it redirects the protocol from http to https, then the already received url redirects c without a slash at the end to with a slash, i.e. in two stages. This is what my SEO swears at. Is it possible to fix this moment? Here's what's happening in my htaccess right now:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /


RewriteCond %{HTTP:PORT} !^443$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteRule (.*)\.html$ $1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !(.*)sitemap.xml$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]

# Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^domain\.ru [NC]
RewriteRule (.*) https://domain.ru/$1 [R=301,L]

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-11-12
@mydarck

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule (.*)\.html$ https://domain.ru/$1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !sitemap\.xml$
RewriteRule ^(.*[^/])$ https://domain.ru/$1/ [L,R=301]

RewriteCond %{HTTP:PORT} !^443$       [OR]
RewriteCond %{HTTP_HOST} !^domain\.ru [NC]
RewriteRule (.*) https://domain.ru/$1 [R=301,L]

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question