To manage a website in a proper way, you must have good understanding of on-page optimization technique, and a little bit knowledge of coding or editing website configuration file like one is .ht access as if you have been hosted your website on Apache server.

Different Ways to Setup 301 Redirect on a Single Domain or between Domains

301 Redirect is the part of the website optimization that you need to understand as a little mistake in this part can cost you a lot. So, first understand properly what 301 Redirect actually is, and how you could implement it correctly on your domain.

What is Actually 301 Redirect?

301 Redirect is defined as the permanent redirect that is used to redirect websites or pages on websites permanently from domain to domain or page to page respectively. You can do this via .ht access file of a website.

Different Cases to Implement 301 Redirect

Redirecting Separate Pages

If you wish to redirect separate pages on a website, then use this code on your .ht access file.

For eg.-

Redirect 301 /oldpage.html /newpage.html

Redirecting between Domains

If you have static pages on your website, then use this:

Redirect 301 / /newdomain.com

If you’ve dynamic pages on your website, then use this:

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

If you wish to redirect files from old domain to a new domain, then use this:

Redirect 301 /oldfile.htm http://example1.com/newfile.htm

WWW to Non-WWW

Redirecting www version of a domain to a non-www version will require you to use this code:

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

Non-WWW to WWW

Redirecting non-www version of a domain to a www version will require you to use this code:

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

Redirecting all Pages on a Website with different Extension

RewriteEngine On
RewriteCond %{REQUEST_URI} .php$
RewriteRule ^(.*).php$ /$1.html [R=301,L]

Probably, You Are Unaware of What Causing Duplicity on Your Website!

Digitizebrand Hub we take initiative to Digitize Business. We are giving extremely affordable top quality digital services, a real helping hand to become true digital India.

Different Ways to Setup 301 Redirect on a Single Domain or between Domains
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *