SEO Post no572

Read Our SEO POST:

Redirect 301, 302 & SEO Best Practices (with lots of How to)

Learn how to SEO your Website!

Tips & Tricks about Content, Local or Technical SEO optimization for every website

Don't miss it! Read my WordPress SEO post and discover tips & trics on "How to optimize my website". Specific code optimization techniques for Pagespeed or GTmetrix reports, to speed up your WordPress and help you reach the top organic rankinks, at the first page of Google results.

Photo of post: Redirect 301, 302 & SEO Best Practices (with lots of How to)

Redirect 301, 302 & SEO Best Practices (with lots of How to)

,What is a 301 redirect?

Redirection is the process of forwarding both users and search engines from a URL of web page to a different URL on another site or server. 301 redirects are particularly useful, if you’ve moved your site to a new domain, and you want to make the transition as seamless as possible. This is the best way to ensure that users and search engines are directed to the correct page. When doing this, it is critical to observe best practices in order to maintain SEO value.

So, 301 redirect is used for permanent changes, meaning that the url you redirect will no longer be used and thus, you want to send your users and the whole web traffic at another web page.

What is a 302 redirect?

For cases in which the redirection truly is temporary, a 302 may be the most appropriate. Many hosting and CDN platforms also offer easy redirection management from their admin panels. With a 302 redirect you are telling to search engines, that the URL you are redirecting, will be soon availiable to the users, but for now, they should read or use another temporary web page.

Only use 302 redirects if you intend to return to the original page in the near future, otherwise it is better to use a permanent 301 redirect. For that reason, all SEO value is kept at the older web page and it is not sent to the new address.

SEO Best Practices for Redirects

Google (and other search engines) have continued to shift focus toward a better user experience, which means they aim to show more reliable, relevant, and high-quality results to users. Now, longer and more comprehensive content that encompasses the topic more in depth are preferred because it provides the user with more information all in one place.
If you decide to rewrite some of your older pages to provide a more comprehensive view of a topic, you can use 301 redirects to transfer the link equity and authority from the existing pages to your newly created or updated website pages.

If you have to delete pages from your site, there are a few things to consider:

      • Is there a similar page you can redirect it to?
      • Should the page be improved or optimized?

Whenever possible, you should always redirect a deleted page to a similar piece of content on your site. If that is not an option, you should consider if deleting the page is the best course of action.

For example, if the page receives traffic and has good quality backlinks associated with it, deleting it could be harmful to your SEO, in which case, it may be worth improving and optimizing the page instead.

How do I set up 301 redirects?

301 redirects are particularly useful. It is a server-side redirect. Typing a URL into your browser or clicking on a link sends a request for the page to the server of the website. A 301, “moved permanently,” redirect is a set of instructions which are executed when the request hits the server, automatically re-routing to a different page. You can set up this kind of redirection by adding the appropriate code in your theme’s .htaccess text file.

By using 301 redirects, you will be transferring all of the existing page authority, link equity, and SEO rankings to the new page, thus creating a more powerful page. The scenarios below can be entered into your .htaccess file as shown. The process is simple and convenient.

Common 301 Redirect Htaccess Rules

Before reading further, here is a quick example of a 301 redirection.

Place the following code inside your theme’s .htaccess file, right after the blue snippet :

<IfModule mod_rewrite.c> #if all text in blue exist,
  RewriteEngine On

#if all text in blue exist, just insert only the two (-2-) following lines

RewriteCond %{REQUEST_URI} ^/my-category/my-product.html(.*)$
RewriteRule ^(.*) https://www.new-domain.com/new-category/new-product/%1 [R=301,L]

</IfModule> # finalize your code with this text in blue (normally it already exists):

Another quick example:

<IfModule mod_rewrite.c>
RewriteEngine On
   RewriteCond %{HTTP_HOST} ^old-domain.com$ [OR]
   RewriteCond %{HTTP_HOST} ^www.old-domain.com$ 
   RewriteRule (.*)$ http://www.new-domain.com/$1 [R=301,L]
</IfModule>

How do you redirect a single page?

Redirect 301 /pagename.php https://www.domain.com/pagename.html

How do you redirect an entire site or domain to a new one?

Redirect 301 / https://www.domain.com/

How do you redirect an entire site to a subfolder?

Redirect 301 / https://www.domain.com/subfolder/

How do you redirect a subfolder to a different website?

Redirect 301 /subfolder https://www.domain.com/

How do you redirect a file extension but retain the page name?

Example: If you want a .html extension to use the same filename but use the .php extension.

RedirectMatch 301 (.*)\.html$ https://www.domain.com$1.php

How do you use rewriting to redirect from an old domain to a new domain?

RewriteEngine on
RewriteBase /
RewriteRule (.*) https://www.newdomain.com/$1 [R=301,L]

How do you use rewriting to redirect from a non-www to a www subdomain?

RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ https://www.domain.com/$1 [r=301,nc]

How do you use rewriting to redirect a domain to a www location with a subdirectory?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} domain.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/directory/index.html [R=301,NC]

How do you use rewriting to redirect from an old domain to a new domain, that includes the full path and query string?

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^(.*) https://www.newdomain.com%{REQUEST_URI} [R=302,NC]

How do you use rewriting to redirect from an old domain with a subdirectory to a new domain, without the subdirectory, but include the full path and query string?

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$
RewriteRule ^(.*) https://www.katcode.com/%1 [R=302,NC]

How do you rewrite and redirect URLs with query parameters, with files placed in a root directory?

Example: The original URL being https://www.website.com/index.php?id=3 and the new URL being https://www.website.com/path-to-new-location/

RewriteEngine on
RewriteCond %{QUERY_STRING} id=3
RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301]

How do you redirect URLs with query parameters and place files in a subdirectory?

Example: The original URL being https://www.website.com/sub-dir/index.php?id=3 and the new page being https://www.website.com/path-to-new-location/

RewriteEngine on
RewriteCond %{QUERY_STRING} id=3
RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301]

How do you redirect a site to HTTPS from HTTP to eliminate duplicate content?

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Easy redirect from HTTP to HTTPS to eliminate duplicate content?

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

How do you remove an index.html or index.php and redirect to the root?

RewriteEngine On
RewriteCond %{THE_REQUEST} /index.php HTTP [NC]
RewriteRule (.*)index.php$ /$1 [R=301,L]

RewriteEngine On
RewriteCond %{THE_REQUEST} /index.html HTTP [NC]
RewriteRule (.*)index.html$ /$1 [R=301,L]

How do you rewrite and redirect URLs with query parameters to a directory-based structure while retaining the query string in the URL root level?

Example: The original URL being https://www.website.com/index.php?id=100 and the new page being https://www.website.com/100/

RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]

How do you rewrite URLs with a query parameter to a directory-based structure while retaining query string parameters in the URL subdirectory?

Example: The original URL is https://www.website.com/index.php?category=fish and the new page being https://www.website.com/category/fish/

RewriteEngine On
RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA]

How do you redirect an old website to a new domain and retain the URL path?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC]
RewriteRule ^(.*)$ https://www.example-new.com/$1 [R=301,L]

If you do not want to pass the path to the new domain, change the last line to:

RewriteRule ^(.*)$ https://www.example-new.com/ [R=301,L]

How do you rewrite and add a trailing slash to URLs without one?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://www.example.com/$1/ [R=301,L]

How do you redirect from a blog subdomain to a blog folder?

Example: Redirection from blog.oldsite.com to www.newsite.com/blog/

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI}/ blog
RewriteRule ^(.*) https://www.somewhere.com/%{REQUEST_URI} [R=302,NC]
RewriteRule ^(.*) https://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC]

How do you redirect one directory to another?

Options +FollowSymLinks RewriteEngine On RewriteRule ^(.*)/old-directory/(.*)$ $1/new-directory/$2 [R,L]

Related tags:
Back to SEO Blog

Dec 2024
This website is releted to the term: Search Engine Optimizion (SEO), or otherwise known as Digital Marketing, in English (USA, Great Britain, Ireland, Australia) or Greek!

Photo credit Image by Pixabay

Guest Posting on: Digital Marketing, from SEO experts...

... Any published article or post on SEO is valid. You can follow any posted recommendations to fix your code in order to get a better score on GTmetrix or PageSpeed Insights. Whenever I find time, I continue developing my website.

Also, if you have a new SEO technique or want to publish a fantastic new SEO strategy online that converts into leads or sales, especially in the e-commerce space, please contact me and I will host your (strictly relative) article, with all proper credits to the author, for at least one month.

Moreover, I will be especially happy if I receive from you an email related to search engine optimization in Greek, which is my native language. Of course, I can provide you with any help you need and it concerns SEO in Greek or creating websites, since I have developed the Wordpress theme that you literally read from scratch. If you are an SEO specialist in Greece, share your opinion with me! So do not hesitate to contact me, I am waiting for you for any advice, question or suggestion to improve my site or anything related to SEO in Greece.

My message in Greek
Θα χαρώ ιδιαιτέρως, αν λάβω από εσάς email σχετικό με search engine optimization στα Ελληνικά, τα οποία αποτελούν τη μητρική μου Γλώσσα. Φυσικά, μπορώ να σας παράξω οποιαδήποτε βοήθεια χρειαστείτε και αφορά SEO στα Ελληνικά ή δημιουργία ιστοσελίδων, μιας και έχω αναπτύξει το Wordpress theme που διαβάζετε κυριολεκτικά από το μηδέν. Αν είστε SEO specialists στην Ελλάδα, μοιραστείτε την άποψή σας μαζί μου! Μην διστάσετε, λοιπόν, να επικοινωνήσετε, σας περιμένω για οποιαδήποτε συμβουλή, απορία ή πρόταση για βελτίωση του site μου ή οτιδήποτε σχετικά με SEO στην Ελλάδα.

SEO Implementations on Websites that I helped to get a better Google Ranking

These are a few websites on which I performed SEO (Search Engine Optimization) and of course, they now get traffic from the first page of Google results.