Saturday, March 18, 2017

How to Redirect URL/Domain to Another URL/Domain

Last Update:

Recommended Cloud & Hosting: Cloudways, Hostinger & BlueHost
301 Redirect moves the URL to another specific URL permanently. It is necessary when the result of redirect-able is shown in search engine (Google, Bing etc.) results or need to redirect older domain to new domain.
MOve URL to another Domain or URL
You can do it with meta tag, JavaScript, htaccess, Java, Perl, Ruby, PHP etc.
Advantage of using 301 Redirect:
1. Automatic redirects visitor or user and search engine to redirected page or URL.
2. Recommended by Google.
3. Make transition between older and newer URL.

It would be better to redirect with htaccess redirect process as below. You can also do it by using 1-9 process.

.htaccess Redirect Process:

Create a .htaccess file in your root directory and paste the following code after customizing domain name and save your template.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.compromath.com/$1 [R=301,L]
If you have no available the htaccess redirect process then you can try the following process.

To redirect URL or Domain in  Blogger/Blogspot user, try 1 or 2.

1. Meta Tag Redirect Process: Add the following tag within title tag.
<meta http-equiv="refresh" content="0; url=http://www.compromath.com/"/>
2. JavaScript Redirect Process: Add the following script just before </body> tag.
<script type="text/javascript">
    window.location.replace("http://www.compromath.com/");
</script>
3. PHP Redirect Code:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.compromath.com" );
?>
4. ASP Redirect Code:
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.compromath.com/"
%>
5. ASP.NET Redirect Code:
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.compromath.com");
}
</script>
6. JSP (Java) Redirect Code:
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.compromath.com/" );
response.setHeader( "Connection", "close" );
%>
7. ColdFusion Redirect Code:
<.cfheader statuscode="301″ statustext="Moved permanently">
<.cfheader name="Location" value="http://www.compromath.com">
8. CGI PERL Redirect Code:
$q = new CGI;
print $q->redirect("http://www.compromath.com/");
9. Ruby on Rails Redirect Code:
def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.compromath.com/" 

Have got this article helpful or not working? Put your comment below.

About me


Elliyas Ahmed
Elliyas Ahmed

Hi, I am Elliyas Ahmed, the founder of ComProMath. I try to share what I learn.

Work With Me - SEO Expert, WordPress, Blogger Theme Developer on Fiverr

Lets Disucss on this Article

Don't try SPAMMING here! Submit your Feedback, Questions or Comment related to this Article. Read our Comment Policy.

No comments:

Submit your COMMENT here