What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.
Home Google Analytics What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.

What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.

by

in

When running your own company’s website, you may sometimes encounter cases like “The website has been renewed and the domain has changed,” or “I was told to redirect from the old address, but I don’t understand what that means.” It will come.

Redirecting means automatically redirecting a page to another page. This time, we will explain the meaning, purpose, types, setting methods, and how to write the .htaccess file of this redirect.



What is a redirect?


A redirect is a mechanism that automatically redirects users to a new URL when the entire website or page is changed to a new URL.

For example, let’s say you change the website domain when you renew your company’s website. What would happen if a user who had bookmarked or favorited the page before the renewal accessed the website by following those bookmarks or favorites after the renewal and was not redirected?

Usually, a “404 page” that means “The page you are looking for cannot be found” is displayed, making users wonder, “Huh? This site has disappeared.” Users may be fooled into thinking that the bookmarked website has disappeared, when in fact it has been renewed and moved to a new page. If that user is an important customer or potential customer for your company, this could lower customer satisfaction or lead to lost opportunities.

From

an SEO

(Search Engine Optimization) perspective, redirecting a page to automatically guide or forward a page to another page is essential when renewing a website. If you are in charge of managing a website, this is something you should know.

Related articles
 What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.



Purpose of redirection


Let’s take a closer look at redirects. The main purposes of redirection are as follows.

  1. Improved usability
  2. SEO measures



Improved usability


As I mentioned earlier, it is very convenient for users of websites to have redirects set up.

If you change the site URL when renewing your company’s website, you can set up a redirect to the new site URL to make users aware that “Oh, this website has been renewed.” , it can also be guided automatically.

On the other hand, if redirect settings are not set after a website renewal and the old website no longer exists, the user may be forced to give up on accessing the website or have to go through the trouble of re-searching with

a search engine

. I’ll probably put it away. Furthermore, if the URL is changed on a page-by-page basis, users will have to navigate around the website again to find the same content.

If this happens, it will cause stress to users and reduce customer satisfaction. Potential customers may also go to competing sites, resulting in a huge opportunity loss.

This type of loss can occur depending on whether you have redirects configured or not. From a usability perspective, redirect settings are extremely important.

Related articles



SEO measures


Redirects are also important from an SEO perspective.

Let’s say you have a website that has been operating for many years and has a fairly high search ranking on Google. What will happen if the URL is changed due to a renewal of the website and no redirect is set?

Google cannot detect that a renewed website is a relocation of a previously rated website, so it recognizes the new website as a completely new website. Naturally, the old website’s reputation will not be carried over, and the reputation it has received from search engines will be reset. In other words, when you search for a certain keyword on Google, even though your website was ranked high before the renewal, it may no longer be ranked high after the renewal.

In this way, redirects are extremely important as they are related to usability as well as SEO measures.

Related articles
 What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.



When to redirect


When is a redirect necessary? Let’s look at a concrete example.

  1. When changing the URL due to site relocation or renewal
  2. If you want to change your site’s domain
  3. If the URLs of the PC site and smartphone site are different
  4. When you want to temporarily redirect to the site maintenance page
  5. When you want to forward to a limited-time campaign page for a certain period of time



When changing the URL due to site relocation or renewal


Redirects are essential when changing the URL when moving or renewing a website.



If you want to change your site’s domain


Redirects may also be performed when adding “www” to a website URL without “www”, or when changing from “http” to ”

https

“, in other words when implementing SSL.

Related articles



If the URLs of the PC site and smartphone site are different


Redirection is also used when a smartphone user accesses a PC site and wants to be automatically redirected to the smartphone site.



When you want to temporarily redirect to the site maintenance page


It is also used when you want to temporarily redirect to a page with a message such as “Currently undergoing maintenance” in the event of a server error.



When you want to forward to a limited-time campaign page for a certain period of time


Redirects may be used when you want to temporarily redirect to a campaign page for a limited time, such as for a week or so.

 What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.



Redirect type


Next, let’s check what types of redirects there are.

There are two types of redirects: 301 redirects and 302 redirects, and client-side redirects and server-side redirects. I will explain each.

Related articles



“301 redirect” and “302 redirect”


301 redirect and 302 redirect indicate how long the redirect will last when setting up a redirect.

301 and 302 are a type of status code established by the W3C (World Wide Web Consortium), an organization established to promote the standardization of web technology.

When a browser displays

HTML

, the common language for web pages, it first receives and processes a three-digit number. The numbers range from 100 to 510, and each number has its own meaning.

Among them, status codes in the 300s indicate redirects. There are 301, 302, 303, and 307, but 301 and 302 should be used when setting up redirects.

  1. 301
  2. 302



301


A status code of 301 means “Moved Permanently”. This indicates that a URL has been permanently and permanently changed to a new URL, and only the new URL will be used from now on.

For example, this is used when you want to continue redirecting in the future, such as when the URL of a page changes due to a website move or renewal.



302


A status code of 302 means “Found”. This indicates that the previous URL will be temporarily redirected to another URL. The redirect destination is a temporary URL, so you need to keep the URL before the redirect.

For example, when a page cannot be displayed temporarily due to a server error, it is used for a limited period of about 1 to 2 weeks, such as when you want to redirect to another page that can be displayed normally.



It is important to use “301 redirect” and “302 redirect” properly.


To summarize the above, 301 redirects are “permanent redirects” and 302 redirects are “temporary redirects.”

From a user’s point of view, the difference may not be obvious because it is the same redirect, but for servers, browsers, and search engines, it is a very important and big difference.

A 301 redirect tells search engines that you have completely moved from the old URL to a new URL, and a 302 redirect tells search engines that you may return to the old URL again. Therefore, when a search engine displays search results, normally it will display the page with the new URL if it is a 301 redirect, and it will display the page with the old URL if it is a 302 redirect.

Therefore, if you use a 302 redirect in the case of a renewal, the new website may not be displayed in search results for a long time, so be careful about this point.



“Client-side redirect” and “server-side redirect”


There are two types of 301 redirects mentioned above: client-side redirects and server-side redirects. I will explain each.

  1. client side redirect
  2. Server-side redirect (HTTP redirect)
  3. Google recommends using server-side redirects



client side redirect


Client-side redirection is a method of writing destination information in HTML. Have you ever found a page with text and links like the one below when searching on Google?

“This site has been moved to a new site. You will be automatically redirected to the new site in 5 seconds. If you are not automatically redirected, please click on the URL below.”

This is most likely due to the redirect being configured on the client side rather than the server side.



Server-side redirect (HTTP redirect)


Server-side redirection, as the name suggests, is a redirection method that is configured on the server. Make appropriate descriptions in the server configuration file called “.htaccess”, upload it to the server, and apply a redirect.

When accessing the pre-redirected URL, the server automatically returns the redirected URL, so the user never accesses the old URL. Even if you access the old URL, you can immediately view the page at the new URL.



Google recommends using server-side redirects


Both client-side redirects and server-side redirects are used when setting up redirects, but Google, the leading search engine, recommends using server-side redirects. The reason is that client-side redirects do not carry over page ratings. In some cases, the pages before and after a redirect may be detected as separate pages, and if this happens, there will be multiple websites posting the same content, which may result in penalties for duplicate content. There is also.

For this reason, if you are implementing SEO measures, it is a good idea to choose server-side redirects.

Related articles
 What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.



How to set up server-side redirect: When using “.htaccess” file


The most common way to set up server-side redirection is to place a file called “.htaccess” on the server.

  1. What is “.htaccess”?
  2. Page-by-page redirection
  3. Directory redirection
  4. Per-domain redirection
  5. If you want to normalize the URL with or without www



What is “.htaccess”?


.htaccess is a configuration file placed on the server, and in addition to redirection, you can perform various settings by writing according to rules.

Create the .htaccess file using a text editor. When configuring redirect settings, write the description in the specified language and save it. Then, upload it to your server, set the appropriate access permissions, and you’re done.

The content to be written varies depending on the redirection method, such as page-by-page redirection or directory-by-directory redirection. We will explain how to write each.



Page-by-page redirects


  1. How to write from page to page, for example, from “http://www..com/aaa.html” to “http://www..com/bbb.html”


(Please change the parts in red to match your site)

[For copying] RewriteEngine on

  1. RewriteRule ^aaa.html$ http://www..com/bbb.html [L,R=301]



    Directory redirection


    How to write when transferring from directory to directory, for example from “ccc directory” to “ddd directory”


    (Please change the parts in red to match your site)

    [For copying]

  2. RewriteRule ^ccc(.*)$ /ddd$1 [L,R=301]



    Per-domain redirection


    How to write from domain to domain, for example, when transferring from “https://www..com/” to “https://www.◆◆.com”


    (Please change the parts in red to match your site)

    [For copying]

  3. RewriteCond %{HTTP_HOST} ^www..com RewriteRule ^(.*) https://www.◆◆.com/$1 [R=301,L]



    If you want to normalize the URL with or without www


    How to write when you want to normalize from with www to without, for example, from “http://www..jp” to “http://.jp”


    (Please change the parts in red to match your site)

    [For copying]

  4. RewriteCond %{HTTP_HOST} ^www..jp$ RewriteRule ^(.*)$ http://.jp/$1 [R=301,L]



    Points to note when setting up redirects using .htaccess files


    The following are the main points to keep in mind when setting up redirects using the .htaccess file.

    Redirect destination needs to be set appropriately

  5. Beware of infinite loops
  6. Be careful with the default strings
  7. Make a backup before setting up redirection



    Redirect destination needs to be set appropriately


    When setting up redirects using the .htaccess file, you need to set the redirect destination appropriately. In particular, when specifying a page-by-page redirect rather than a redirect between websites, you must set the URL of the new page that inherits the contents of the old page.

    When users are redirected to the top page of a new website, they will have to search for the page themselves, which increases the possibility that they will find it time-consuming and leave the website. To prevent this from happening, you need to specify an appropriate URL when specifying a redirect destination for each page.



    Beware of infinite loops


    Redirects can cause infinite loops if configured incorrectly.

    For example, if you make two statements such as “transfer from old website to new website” and “transfer from new website to old website,” the new website will redirect you to the old website again. This means that the transfer will be repeated endlessly. Not only will your old and new websites not be displayed, but your server will also be overloaded.

    To prevent this from happening, you must be very careful not to cause an infinite loop due to a writing error.



    Be careful with the default strings


    Especially if you are using WordPress as your CMS, you need to be careful about the strings that are pre-written in the .htaccess file.

    If you make even the slightest change or delete any of these strings, the website may no longer display correctly. Specifically, it is the part below surrounded by “# BEGIN WordPress ~ # END WordPress”.

    # BEGIN WordPress

  8. RewriteRule . /index.php [L] # END WordPress

    Be very careful when working to avoid modifying the redirect processing code by mistake.



    Make a backup before setting up redirection


    As you can see from the above explanation, we recommend that you take a backup before setting up redirection.

    If you change the .htaccess description and it becomes irreversible, your website may not be able to return to its original state. In such cases, it is a good idea to be able to easily return to the state before modification using “Restore”.

     What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.



    How to set up server-side redirect: For WordPress


    If you want to set up a redirect in WordPress and don’t want to make changes to the .htaccess file, we recommend using a plugin called “Redirection.”

    By using this plugin, you can easily set up redirects by simply entering the source and destination URLs. You can also check the URLs set for redirect as a list.



    How to set up Redirection


    1. Log in to WordPress

    2. Click “Plugins” on the left side of the management screen

    3. Click “Add new plugin” at the top of the screen

    4. Enter “Redirection” in the “Search Plugins” field

    5. When the Redirection plugin appears, click “Install Now” to install it.

    6. An “Activate” button will be displayed, click to activate it.

    7. “Redirection” will be added to the plugin list, then click Settings.

    8. Enter the “Source URL” and “Target URL” and click “Start Setup”.

    9. Go to the “Basic Setup” page

    10. You can select check items, so select as necessary (basically we recommend checking all).

    11. Click “Next” and you will be redirected to the “REST API” page and will be automatically verified.

    12. If “Good” is displayed on “REST API” after a few seconds, the settings are correct.

    13. Finally, click “Setup Complete”

     What is a redirect? Explains the type, setting method, how to write HTACCESS files, etc.



    Things you should not do when setting up redirects


    There are some things you should avoid doing when setting up redirects. However, it basically depends on a case-by-case basis, and it does not mean that you should absolutely avoid it. Knowing this information will be useful for future website management.

    Redirection with HTML “meta refresh”


  9. JavaScript

    redirection
  10. Crypt redirection



    Redirection with HTML “meta refresh”


    There is a transfer setting method using the description “meta refresh”. This is one of the client-side redirect methods.

    Redirect settings can be made by writing in the HTML of the page you want to redirect. This method can be said to be very convenient since it is easy to write.

    However, as mentioned earlier, this client-side redirect method may not be able to carry over Google’s search engine rankings, so it is said to be best avoided from an SEO perspective.



    JavaScript redirection


    You can also perform redirects using JavaScript, a programming language available for websites. Server-side redirection may not be possible depending on the server environment, but this method is often used as an alternative.

    However, it is important to note that if the user has disabled JavaScript in their browser settings, the redirect will not occur.



    Crypt redirection


    Crypt redirection is a redirection method in which the user who visits the site clicks on the link and moves to the redirected destination. Notify in advance that the site has been transferred to a web page, and paste the link.

    This is a very easy method to set up, but Google recommends 301 and 302 redirects that are set up on the server side, so it may not be recognized as an official redirect method. We recommend that you use this method only as a temporary measure.



    About after redirect setting


    Next, we’ll provide you with some useful information on what to do after you set up a redirect.

    How to check if redirect settings are set

  11. How long does it take to be reflected in search engines?
  12. How long should I set up 301 redirects?



    How to check if redirect settings are set


    After setting up a redirect, make sure to access the page where you set the redirect in your browser and check if the redirect is being sent correctly.

    Another option is to use a check tool that allows you to check the status of redirects, such as whether they are being performed correctly. There are many free tools that you can check on the website, so it’s a good idea to look for one that is easy to use.

    Here we introduce the following three rules.

    ohotuku.jp

  13. Redirect Path
  14. Chrome developer tools



    ohotuku.jp



    ohotuku.jp
    ” is a website that collects tools that can check SEO. There are tools such as ranking check tools, keyword selection tools, and keyword appearance rate checks, and one of them is the redirect check tool.

    This redirect check tool allows you to check if your 301 redirects are working correctly. It is very easy to use, just enter the URL in the URL input field and click the “Check” button. The number of redirects will be displayed, and whether or not you have been redirected will be displayed.



    Redirect Path




    Redirect Path

    ” is provided as a Google Chrome extension. It’s very easy to use, just install Redirect Path in Google Chrome and access the URL before being redirected.

    If you want to check the redirect status code, check the Redirect Path icon in the top right corner of your browser and the code will be displayed. If the expected code is displayed here, the redirection has been performed correctly. If a code different from the expected code is returned, the settings may be incorrect.



    Chrome developer tools


    “Chrome Developer Tools”, like the above item “Redirect Path”, is a tool that uses Google Chrome to check the operation of redirects. However, while “Redirect Path” is an extension, developer tools are a standard feature of Google Chrome.

    Since it is a standard feature of Google Chrome, it is extremely functional and allows you to check information such as the HTML structure of a website. This section explains how to start the developer tools and how to check their operation.

    How to start on Windows

  15. How to start on Macintosh (Mac)
  16. Steps to check redirect operation using developer tools



    How to start on Windows


    The startup method on Windows is as follows.

    1. At the top right of Google Chrome, click the three vertical dots (


    )” Click

  17. 7. The redirect operation status will be displayed under the item “General”



    How long does it take to be reflected in search engines?


    If you set up a 301 redirect, you may be wondering how long it takes for search engines to recognize it correctly. It depends on the frequency of the crawl, but it usually takes anywhere from a few days to a few weeks. Be patient and check to see if it appears in the search results.



    How long should I set up 301 redirects?


    We introduced 301 redirects as a permanent redirect method. Once you’ve set it up, you may wonder how long you should continue setting it up.

    In fact, once your site is recognized by search engines, you may think it’s about time and want to remove the 301 redirect.

    However, if you cancel the 301 redirect, the information that you want the new URL to be indexed will no longer be communicated to the search engines, so you may lose the search engine reputation that you have built up using the old URL.

    Therefore, as long as you want to retain the reputation of the old URL and users are still accessing the old URL, you will need to continue to maintain redirects.



    About Google’s “Redirect Warning” and “Unauthorized Redirect”


    You may come across Google’s “Redirect Warning” page. Additionally, while using Google Search Console, you may receive a notification that you have been redirected incorrectly.

    To deepen your knowledge about redirects, be sure to know about these two.

    Redirect warning

  18. illegal redirect



    Redirect warning


    A “redirect warning” is a warning page that may appear when you click on a link while searching on Google’s search engine. This is a deliberate warning by Google.

    If a user visits a page and discovers that the destination page has a potentially dangerous redirect, a page with the title “Redirect Warning” and a message similar to the following appears: will be displayed.

    “The page you are currently viewing is about to redirect you to http://www..com/. If you do not want to be redirected to this page, please return to the previous page.”

    The http://www..com/ part is a dummy URL. In fact, the URL of the redirect page that is considered to be dangerous is displayed here.

    By including these pages, Google prevents users from accessing pages that maliciously redirect users to dangerous pages.

    It seems that this warning is issued when there is a possibility that an inappropriate redirection is occurring. This is especially true when the destination page is at risk of being infected with malware or hacked.

    If you, as a user, encounter such a warning page, we recommend that you carefully check whether the destination is appropriate before accessing it.

    However, just because you see this warning page does not necessarily mean that all redirects are malicious. It is said that this warning may appear even with redirects that should be fine.



    illegal redirect


    Google calls redirect that violates guidelines for Google webmasters “fraudulent redirect”. If you are using Search Console, you may receive a message from the Search Console, such as “Redirect on your website is fraudulent.”

    The fraudulent redirect defined by Google is that “search engine has one content type, but users are redirected to completely different content” and “PC users have normal pages for PC users. However, mobile users are redirected to a completely different spam domain.

    Google states that these redirect methods indicate different content on human users and Google search engines, and can move users to different places from the expected location. I am.

    Google also states that “redirect using JavaScript” may be an illegal act. However, if you want to redirect to the internal page after logging in the user, it is recommended to use JavaScript, so it is recommended to read the guidelines.

    The 301 redirect is said to be optimal when relocating the website, but if you cannot access the server of the website, it is no problem to use JavaScript redirect for this purpose.

    Related articles



    What if you receive a “illegal redirect” message?


    It is said that it is rare to receive a message that is an unauthorized redirect in the Search Console, but if you receive it, there is no problem if you deal with it properly according to the message.

    The solution is a case -by -case, but if you set 301 redirect on the server side direct directly recommended by Google, there is almost no problem.



    summary


    ◆ Redirect is a mechanism to automatically transfer to a new URL when the entire website or page is changed to a new URL.

    ◆ The main purpose of redirect is improving usability and SEO measures.

    ◆ For timing when redirection is required, when changing the URL by relocating / renewing the site, changing the site domain, when the PC site and the smartphone site URL are different, when you want to temporarily transfer to the site maintenance page. There are times when you want to transfer to a limited time campaign page for a certain period of time.

    ◆ Redirect types include the classification of “301 redirect” and “302 redirect”, and “client side retirection” and “server side retirection”.

    ◆ When setting redirect using a .htaccess file with a server side retirect, describe a language such as “RewriteEngine on” and upload it to the server.

RewriteEngine on RewriteEngine on RewriteEngine on RewriteBase ^index \ .php $? Name}! -F RewriteCond %{Request_filename}! -D 2. From pull-down menu to “Other tools” on mouse 3. Select “Developer tool” from the more displayed pull -down menu 4. Developer tool starts.