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.
Purpose of redirection
Let’s take a closer look at redirects. The main purposes of redirection are as follows.
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.
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.
When to redirect
When is a redirect necessary? Let’s look at a concrete example.
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.
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.
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.
“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.
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.
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.
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.
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
(Please change the parts in red to match your site)