top of page

What Are The Different Types Of Redirects On Websites And How To Do Them [2023]

URL redirects are a technique used by SEO professionals to make a specific web page available by forwarding it to another URL address, without the data being lost. On the user’s side, when they try to open a page that has been redirected, a second page is opened with a different URL from the first, which may or may not have the same content as the previous one. There are various types and statuses of redirects:

  • 300 – Multiple Choice, links can be taken with status 200 – OK (this is a manual redirect),

  • 301 – Moved Permanently;

  • 302 – Found and Moved Temporarily;

  • 303 – Indicates that the redirect does not lead to recent resources, but to a confirmation page, e.g. form thank you pages;

  • 304 – Not Modified, cache update, indicates that the cache value is still recent and can be used,

  • 307 – Moved Temporarily, similar to 302, but this redirect does not maintain PageRank;

  • 308 – Moved Permanently, this redirect also does not maintain PageRank.



HTML Redirects

To create a redirect in the HTML of a website page, developers can create a “meta” element and the “http-equiv” – attribute defined as refresh in the page header. When displaying the page, the browser will find this element and go to the indicated page. The “content” is the attribute that starts with a number to indicate how many seconds the browser should wait before redirecting to the URL provided. Always set it to 0:


<head> 

<meta http-equiv=”refresh” content=”0; URL=http://www.example.com/” />

</head>


JavaScript Redirects

JavaScript redirects are created by setting a value for the “window.location” property and the new page is loaded. This redirect will only work on clients that run JavaScript:


window.location = “http://www.example.com/”;


Example code for the redirection approach:


fetch(`/api/products/${productId}`)

.then(response => response.json())

.then(product => {

  if(product.exists) {

    showProductDetails(product); // shows the product information on the page

  } else {

    // this product does not exist, so this is an error page.

    window.location.href = ‘/not-found’; // redirect to 404 page on the server.

  }

})


Example code for the noindex tag approach:


fetch(`/api/products/${productId}`)

.then(response => response.json())

.then(product => {

  if(product.exists) {

    showProductDetails(product); // shows the product information on the page

  } else {

    // this product does not exist, so this is an error page.

    // Note: This example assumes there is no other meta robots tag present in the HTML.

    const metaRobots = document.createElement(‘meta’);

    metaRobots.name = ‘robots’;

    metaRobots.content = ‘noindex’;

    document.head.appendChild(metaRobots);

  }

})


Redirection Loops

Loops happen when successive redirects follow one that has already been followed, i.e. a redirect to a certain link had already been created and this one was redirected again to a new page. Most of the time, this is a server problem. If you encounter this error just after modifying a server configuration, it’s probably a redirect loop: 500 (Internal Server Error).


In other cases, it may be a browser error due to cookies, so you need to clear the history manually. Another option that may solve the problem if you’re using wordpress: disable and re-enable all the plugins you have on the site, it may be this type of error. In other cases, it’s related to the security protocol (SSL), so you’ll have to set the SSL back to the default settings and refresh the page. If the error message is still there, try completely resetting your SSL certificate. You can also check .htaccess, the file that controls most page redirects: reset it with an FTP client (Control Panel):

  • Use your FTP client to find your site’s files;

  • Access the WordPress file folder via “Online File Manager”;

  • Go to your htdocs folder;

  • Find the .htaccess and download it (in case you need to restore it later);

  • Right-click to edit. You can now use the web text editor;

  • Reset the default settings; then save and update your site;

  • If this hasn’t resolved the error, you can restore the .htaccess file you downloaded earlier.


Redirects On Common Servers

In Apache, redirects are defined in the “.htaccess” file of each directory. The URL “http://example.com/” will be redirected to http://www.example.com/:


<VirtualHost *:80> 

ServerName example.com 


Redirect_Match does the same, but uses a regular expression to define a collection of URLs that are affected, for example, all documents in the “images/” folder will be redirected to a different domain:


RedirectMatch ^/images/(.*)$ http://images.example.com/$1


In “Nginx” you create a specific server block for the content you want to redirect:


server { listen 80; server_name example.com; return 301 $scheme://www.example.com$request_uri;}


To apply a redirect only to a folder or a subset of pages, use the “rewrite” directive:


rewrite ^/images/(.*)$ http://images.example.com/$1 redirect;

rewrite ^/images/(.*)$ http://images.example.com/$1 permanent;


Implementing redirects differs depending on the CMS you use. You can do it via the site’s .htaccess file, by adding a server block to the nginx.conf file, by using the “Easy Redirects Manager” plugin on WordPress, or by using “Rank Math”, which has a series of SEO-related tools.

 

Conclusion

Redirects are a way of directing traffic (or search engine bots) from one URL to another, this is extremely important for a website, but we must bear in mind that we must redirect a URL to the most similar content to it, as Google may redirect that link back to a 404 page.


Today, many companies need immediate results, but the truth is that they cannot afford to implement SEO internally while leveraging with the priority of their business focus. If you still can’t handle these steps or don’t have the time to put them in place, Bringlink SEO ensures you get the brand visibility and growth you deserve.


Talk to us, send email to bringlinkseo@gmail.com.


 

REFERENCES



bottom of page