Redirect

Redirecting your domain.com to www.domain.com

April 19th, 2010

With people taking steps to make their website search engine friendly, there are some basic things which can be done to get on the better side of Google. Redirecting non www domains to www domains avoids the issue of duplicate content being indexed on search engines.

Below is the code which you need to put in your .htaccess which will redirect any user who types in yourdomain.com to www.yourdomain.com

RewriteEngine on

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

Please change example.com to your website url.

How can i redirect Root to a Folder on my hosting?

February 7th, 2010

Using .htaccess you can very simply redirect your root to a folder on your website. For e.g. when someone would type example.com they would be automatically be redirected to example.com/folder/index.html

To do the above, please add the following line in your .htaccess

RedirectMatch permanent ^/$ http://example.com/folder/index.html

Please replace example.com and folder with your hosting details.

How to Redirect Web Page using HTML or PHP?

January 22nd, 2010

There are many times when you would like to redirect one particular page on your website to some other page or to a different url altogether. There is a very simple way to accomplish this.

Using HTML / PHP redirect

If all your pages are HTML pages, then HTML redirect would be the best option for you. You can either create a new file and place the script in it or you can use your existing .html or .htm file and add the code to it.

Place the following HTML redirect code between the and tags of your HTML code.

<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.example.com/index.html"> 

The above HTML redirect code will redirect your visitors to another web page instantly. The content=”0; may be changed to the number of seconds you want the browser to wait before redirecting.

However if you wish to redirect a PHP file, then the below code would be the best option for you. Make sure that you just have the below code on the file and nothing above it. This code should be the first thing the server reads.

<?php header( 'Location: http://www.example.com/new_page.html' ) ;?>

Note: You would need to change the example.com to your domain name.

Related article:
1. Redirect Main Domain to Sub Domain using .htaccess

Redirect Main Domain to Sub Domain using .htaccess

January 22nd, 2010

There are two simple ways to redirect your main domain to any sub-domain.

1. Using php / html redirect
2. Using .htaccess

In this article i will show you how to redirect using .htaccess. If you already have an .htaccess file in your root folder then open to edit it, else create a new one using note pad and then cut and paste the code below.

Note: Please change the url to your own domain name.

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC] 
RewriteRule ^ http://subdomain.example.com [R,L]

Related article:
1. How to Redirect a folder to a Subdomain using .htaccess

How to Redirect a Subdomain using cPanel

August 19th, 2009

You might want your sub domain to redirect to another page. To do this, please do the following:

After logging on to your cPanel:

1. Click Sub domains
2. Make sure you have already added a sub domain to your account.
3. In the drop down menu to the left of the Setup Redirection select the sub domain for which you would like to redirect
4. Click setup redirection
5. In the box type the domain/Path for which you would like a user to be redirected to if the go to the sub domain
6. Click Save

You have now successfully created a redirect for a sub domain. When you go to the sub domain you will be redirected to the desired page.

Subdomain Redirect using cPanel