SEO

Redirects

Learn about the different type of redirects that you can add to you .htaccess for SEO.

June 9, 2018

What is a Redirect?

A redirect is a way to send both users and search engines to a different URL from the one they originally requested. The three most commonly used redirects are 301, 302, and Meta Refresh.

Getting Started with redirects

All redirects are done within your .htaccess file on your website. Note: This is a hidden file type so you might need to enable the view of hidden files on your server to see it.

301 redirect for SEO

This is a permanent redirect that must be done when you modify the URL structure of a page that is already ranking in the search engines. This is so you don't lose the ranking power of the old URL on the new URL.

Here is an example of a 301 redirect: Redirect 301 /oldurl/ http://your_domain.com/newurl/ and it is important to remember that you need to capture the redirect without the trailing slash as well like this: Redirect 301 /oldurl http://your_domain.com/newurl/.

So for instance if this is the URL of you old page https://mathewlaverty.ca/blog/seo/ and you have changed the URL to https://mathewlaverty.ca/blog/search-engine-optimization/ then your full 301 redirect will be:

Redirect 301 /blog/seo/ https://mathewlaverty.ca/blog/search-engine-optimization/ Redirect 301 /blog/seo https://mathewlaverty.ca/blog/search-engine-optimization/

To redirect non-www to www

Do you want your website to appear as http://www.your_domain.COM rather then http://your_domain.COM then this is the redirect for you. It is important that you do this redirect or you will actually have 2 versions of your site indexing in Google. One with the www and one without.

RewriteCond %{HTTP_HOST} ^your_domain.com$ RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]

To redirect www to non-www

Do you want your website to appear as http://your_domain.COM rather then http://www.your_domain.COM then this is the redirect for you. It is important that you do this redirect or you will actually have 2 versions of your site indexing in Google. One with the www and one without.

RewriteCond %{HTTP_HOST} ^www.your_domain.com$ RewriteRule ^(.*)$ http://your_domain.com/$1 [R=301]

To redirect non-www to www (while using SSL)

Do you want your website to appear as https://your_domain.COM rather then https://www.your_domain.COM then this is the redirect for you. It is important that you do this redirect or you will actually have 2 versions of your site indexing in Google. One with https and one with http.

RewriteCond %{HTTP_HOST} ^your_domain.com$ RewriteCond %{SERVER_PORT} ^443 RewriteRule ^(.*)$ https://www.your_domain.com/$1 [R=301]

To redirect www to non-www (while using SSL)

Do you want your website to appear as https://your_domain.COM rather then https://your_domain.COM then this is the redirect for you. It is important that you do this redirect or you will actually have 2 versions of your site indexing in Google. One with https and one with http.

RewriteCond %{HTTP_HOST} ^www.your_domain.com$ RewriteCond %{SERVER_PORT} ^443 RewriteRule ^(.*)$ https://your_domain.com/$1 [R=301]

Explore more...

Previous
Previous

View the previous blog post.

Go Now
SEO
Back to SEO

Return to Category

Go Back
Next
Next

View the next blog post.

Go Now