DNS - How to Create a 301 Redirect on a Domain

Modified on Wed, 7 Apr, 2021 at 8:18 PM

Answer ID: 352


How do I create a 301 redirect on my domain?


Creating a permanent 301 redirect to point to another website is the best way to point to another website without negatively impacting SEO ranking.


Here is an article with more info about why you would want to create a permanent 301 redirect: 

https://blog.hubspot.com/blog/tabid/6307/bid/7430/what-is-a-301-redirect-and-why-should-you-care.aspx


There are two methods for creating a permanent 301 redirect for a domain, using Host Records and the Scripting Method. The Host Records method is the easiest for domains using our DNS.



Host Records Method


You must be using our DNS servers to use this method (see "How to Change Domain Nameservers (DNS)"). Set the below host records to perform a 301 redirect to http://www.example.com/:

 

Host Name
Record Type
Address
www
URL Redirect
http://www.example.com/?redir_mode=301
@
URL Redirect
http://www.example.com/?redir_mode=301
*
URL Redirect
http://www.example.com/?redir_mode=301

 

Please see the article, "Change Host Records - Forward, Redirect, or Point Your Domain/Sub-Domain" for full instructions on setting host records.



Scripting Method


In order to create a 301 redirect using this method you will need a place to host an index.asp or index.php file.


If you have already signed up for our web hosting you can place this file in your hosting account. You can also point your domain to another host by modifying your name servers or host records (see "How to Change Domain Nameservers (DNS)" and/or "Change Host Records - Forward, Redirect, or Point Your Domain/Sub-Domain").


To purchase a hosting account with us, please see the article, "Purchase Web Hosting".


To create the redirect, use the following code and place it into a file named index.php or index.asp. Then, place the file into the root directory for your domain in your hosting account (see "Web Hosting: Upload Files to Web Hosting Account").


You can modify the location in each file, http://www.example.com, to any URL you choose.


301 Redirect in PHP

<?php

Header( "HTTP/1.1 301 Moved Permanently" );

Header( "Location: http://www.example.com" );

exit();

?>



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article