Causes of redirect errors and remedies

When using the Google Search Console, you may receive an email stating "A new'index coverage'problem has been detected."

This time, I will explain the cause of the error called "redirection error" and how to improve it.

See also here for index coverage

Cause of redirect error

A redirect error is displayed when there is an error in the redirect process. Redirection refers to the process of automatically forwarding a user who visits a specified website to another specified page.
A common example of a domain is when the domain is SSL-enabled (transition from http to https) or when the URL of the page is changed.

Redirection error

Redirects can be used to crawl pages that have changed URLs, even if the page has changed.
Even if the URL of the page changes, if you can explain the redirect process to the crawler, the domain power that affects SEO will continue to be inherited.

See also here for domain power

However, if this redirect is not set correctly, the crawler will not be able to crawl to the destination URL, and the SEO effect will not be inherited and will adversely affect the number of inflows to the website.
If you're getting redirect errors, make sure the redirect is what you intended.

By the way, in Search Console Help, about redirect error

Redirect error: Google has one type of redirect: the redirect chain is too long, a redirect loop is occurring, the redirect URL eventually exceeds the maximum length of the URL, or the redirect chain URL is invalid. An error has occurred. Use a web debugging tool such as Lighthouse to get more information about redirects.

Is explained.
After all, it is not desirable that redirects are performed multiple times.

How to improve redirect error

For visitors, there is a solution for "cookies", but this time we will introduce the countermeasures for the site operator.

Check what the target URL is like

Let's start by knowing what the page being treated as an error looks like.
As I mentioned earlier, the fact that this error is occurring isSituations where there are too many redirects (looped)Is most of the time.
You can also check with the chrome extension etc., but this time, I will introduce this because there is a page that tells you the redirect status just by entering the URL.

Redirect check tool
Redirect check

After identifying the redirect that is causing the loop, modify / invalidate the file (.htaccess, CMS plug-in, etc.) that sets the redirect.
However, it is a very important file for the site such as .htaccess, so if you are not confident, please change the description carefully.

Correspondence by cause of redirect loop

There are various causes for redirect loops in WordPress, but they can be broadly divided into permalink failure, theme function redirect setting failure, some plugin redirect setting failure, https setting failure, etc. ..

When the cause is incorrect setting of URL or permalink

If a redirect loop occurs due to a change in the site URL or directory change, the site URL settings and permalink settings may not be described correctly. In the first place, if you can not log in to the management screen, first try to describe it in wp-config.php as follows.

Code to add to wp-config.php
define('WP_HOME','http://ワードプレスのサイトトップページURL'); define('WP_SITEURL','http://ワードプレスのインストールディレクトリURL');
Code language: JavaScript (javascript)

Next, access http: // WordPress installation directory URL / wp-admin /, log in, and go to "Settings" → "General" on the administration screen.

WordPress address (URL) → http: // WordPress site top page URL
Site address (URL) → http: // WordPress installation directory URL

Let's write and update correctly.

Reset the permalink

Next, go to "Settings"-> "Permalink settings" on the management screen, and press the "Update changes" button at the bottom of the page.
(If an error indicating that .htaccess could not be written is displayed, write the content displayed on the error screen directly to the .htaccess file using FTP software etc.)

As a result, the permalink settings are automatically written out with the correct values, which may resolve the setting error.

If the cause is a plugin

The plugin may be causing a redirect loop. In this case, if you find the plugin, stop it, and the redirect loop on your site is resolved as a result, you need to review the plugin settings again.

W3 Total Cache

The redirect loop phenomenon that is common with this plugin can be fixed by adding www. To the above URL settings on the site.

WPtouch

WPtouch redirects the URL to the mobile site when the user visits the site on mobile.
This feature can cause redirect loops if it is incompatible with other plugins.

The workaround is to add a setting that does not specify the redirect function at the time of mobile access with other plugins.

Redirection

As the name implies, the Redirection plugin is a plugin that allows you to add various redirect settings to WordPress.
Wrong However, once you write the wrong settings here, a redirect loop may occur.

It takes time, but let's verify the settings one by one to see if they are in a strange state.

If the cause is the WordPress body or the theme function

The main body of WordPress includes a function to freely redirect various URLs. The theme may be using this feature and a redirect loop may occur.
Forcibly stopping some of WordPress's redirect functions may break the redirect loop.

However, I don't recommend it because it's a fairly aggressive method, but if you can't seem to solve it by other means, please consider it.

Try adding this to the top of your theme's functions.php.

Code to add to functions.php
remove_action('template_redirect', 'redirect_canonical');
Code language: JavaScript (javascript)

When the cause is a redirect loop due to https conversion

After converting WordPress to https and setting the redirect from http URL to https, a redirect loop may occur.

Here are some typical solutions in this case.

Check if the URL of the site is set correctly

Please check if https is included in the URL setting of the site from "Settings" → "General" on the management screen.
Also, try adding www. Before the domain name to see if the redirect loop breaks.

Modify wp-config.php

Customize the theme and add the following description at the end of wp-config.php

Code to add to the end of wp-config.php
$_SERVER['HTTPS'] = 'on';
Code language: PHP (php)

When the message "You do not have sufficient access rights to access this page" is displayed when you log in to the management screen.

This may happen when you support wp-config.php.
In that case, delete the description of "$_SERVER ['HTTPS'] ='on';" in wp-config.php.

"Define ('ABSPATH', dirname (__ FILE__).'/');"

Under the part

Code to add to the end of wp-config.php
$_SERVER['HTTPS'] = 'on'; $web_site = 'sample.jp'; $web_site_url = 'https://' . $web_site; define('WP_HOME', $web_site_url); define('WP_SITEURL', $web_site_url); define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true);
Code language: PHP (php)

For sample.jp, please enter the domain URL of your WordPress.

summary

Finding the "cause" of the redirect problem is the most difficult part, but please try the methods introduced here one by one and work patiently to find out the cause.

If you leave it alone, the user who visited you will be left behind, and the worst case of withdrawal with unpleasant feelings is waiting.

Please feel free to contact us if you have any questions.

I'm sure some of you may be worried when you suddenly receive a warning email.

I hope this article will be of some help to you.

There were a lot of technical talks this time, so I think there are some difficult parts if you don't have some knowledge of the web.

If you have any questions after reading the article, feel free to Twitter (@kaznak_com) Etc., please ask.

Please excuse me.

Kazuhiro Nakamura
Kazuhiro Nakamura
Representative of Cocorograph Inc. 13 years of SEO history, more than 970 sites with countermeasures. We provide SUO, an upward compatible service of SEO that optimizes not only search engines but also search users. SEO / SUO's original report tool, Sachiko Report Developer. Book "The latest common sense of SEO taught by professionals in the field"
Kazuhiro Nakamura
Kazuhiro Nakamura
Representative of Cocorograph Inc. 13 years of SEO history, more than 970 sites with countermeasures. We provide SUO, an upward compatible service of SEO that optimizes not only search engines but also search users. SEO / SUO's original report tool, Sachiko Report Developer. Book "The latest common sense of SEO taught by professionals in the field"