You may have tried to visit the site before and waited for the page to load, but instead was greeted by an error message. "404 Page Not Found" Error is one of the most famous. There are several reasons why a page may not load, and each has its own code. These codes are called HTTP status codes.

In addition to informing the site visitor of the error, the codes have several other uses. Status codes can take the form of redirects. Redirects created on the front end of your WordPress website must also be reflected on the static website. With the right procedure, this can be achieved thanks to FLATsite technology. Today we want to offer you a detailed guide to setting the status code 301.

Status code 301

The user should theoretically not even see status code 301 because it indicates that the site has been permanently moved from one location to another. For this reason, we know it as a redirect. 301 (redirect) redirects you seamlessly to a URL you did not enter, often without you even noticing. For example, you would type myflatwebsite.com and after loading the page you would see the address www.flatwebsite.com instead.

301 redirects are not created automatically - they must be done by the site owner. Thanks to redirecting search engines, they know that they should not search for the page in the old site, but in the new one.

When to use 301 redirects?

  1. To reassure customers about safety: When a customer shares their personal or financial information with you, it is important to make sure they are safe. The best way to do this is to display the httpx prefix even if it is not specified.
  2. To maintain site authority: a web is a set of web pages, so it makes sense that each page has the same number of common web addresses. Therefore, search engines know how to match all your websites to one site and improve your SEO rankings.
  3. If multiple URLs point to a single site: 301 redirects are useful when there are multiple URLs for the same address. You select a canonical domain (preferred web address) and redirect all other addresses to it.
  4. When changing the domain name: To avoid losing customers after changing the URL, it's a good idea to use 301 redirects and get customers to a new site. They won't be frustrated if they can't find your site and discourage them from finding a new domain.

Creating a Redirect 301

Since you already know when you should use redirection, we can show you how to set it up. Each platform works differently. For example, WordPress web authoring software has plugins that could help you, but you can also use an .htaccess file to create a redirect. HTML sites require you to enter relevant code.

FLATsite can automatically find all the correct 301 redirect configurations on your WordPress site and publish a static version with the changes made.

Server redirects

As mentioned, 301 redirects are not automatic, so they must be created by the site developer. This operation is performed at the server level or using the server to make the instructions apply to the entire site. The two server-level operations we will pay attention to are redirection from www to non-www and vice versa and redirection from HTTP to HTTPS and vice versa.

  1. How to create a redirect to www

To create a 301 redirect from a www domain to a "naked" domain (without the www), you'll need to paste the following code into your .htacces file:

RewriteEngine On
RewriteCond% {HTTP_HOST} ^ www.yourdomain.com [NC]
RewriteRule ^ (. *) $ Http://yourdomain.com/$1 [L, R = 301]

To redirect from a "naked" domain to a www domain, paste the following code into the .htaccess file:

RewriteEngine On
RewriteCond% {HTTP_HOST} ^ yourdomain.com [NC]
RewriteRule ^ (. *) $ Http://www.yourdomain.com/$1 [L, R = 301]

Remember, this is just sample code. Instead of "yourdomain", you must enter your own domain with the URL in the code.

  1. How to create a redirect to HTTPS

If you only activate the SSL certificate now, you need to create a 301 redirect, because you will now use the HTTPS prefix. Enter the following code at the beginning of the .htaccess file:

RewriteEngine on
RewriteCond% {HTTP_HOST} ^ yoursite.com [NC, OR]
RewriteCond% {HTTP_HOST} ^ www.yoursite.com [NC] RewriteRule ^ (. *) $ Https://www.yoursite.com/$1 [L, R = 301, NC] ”

Don't forget to enter your own web address.

301 redirects and SEO rankings

301 redirects could only affect your site's ranking on search results pages until 2016. Google considered the redirected and "new" sites to be two independent entities, with the old rating remaining, but the new site had to acquire it. Since then, Google has adapted and minimized the 301 redirect penalties. Today, a redirected page transfers most of its value to a "new" page.

301 redirects can help more than just retain customers. For example, changing the site from HTTP to HTTPS should improve your ranking, because Google also monitors the security of websites when they rank in search results. On the other hand, if you don't change all aspects of your site from HTTP to HTTPS, visitors to your website will encounter an error message. This is called an unsecured / mixed content alert.

Alerts for insecure and mixed content

Alerts for insecure or mixed content inform visitors about dangerous elements, although there may be some secure elements on the website (they have been changed to HTTPS). These sites cannot be loaded because it is not possible for HTTP and HTTPS content to load at the same time. In this way, Google tries to force websites to take the basic security protocol seriously. Failure to do so will be penalized.

At the end

301 redirects are necessary if you want to direct customers to a new website without having to remember the new URL themselves. If done correctly they shouldn't hurt you and can even improve your position on the search results page. All properly configured 301 redirects will be performed by FLATsite technology called a web crawler, and changes will be automatically reflected on your static page.

EnglishSlovak