How to redirect domain

m
 
Line 1: Line 1:
 +
<seo title="How to redirect domain" metakeywords="http redirect,redirect domain,301 redirect" metadescription="How to redirect domain" />
 +
<br>
 
<span style="color:#B0C4DE"><FONT SIZE="+1">'''Domain redirect in cPanel'''</FONT></span>
 
<span style="color:#B0C4DE"><FONT SIZE="+1">'''Domain redirect in cPanel'''</FONT></span>
Redirect/redirection is a way of forwarding site visitors to a different web page than the one they request. This is done for various reasons (e.g. the original page is unavailable or is still being designed).
 
Redirects can be set either via cPanel or via .htaccess file. This tutorial will explain how to create a redirect via your hosting account cPanel.
 
  
 +
<div align="justify">'''Redirect/redirection''' is a way of forwarding site visitors to a different web page than the one they request. This is done for various reasons (e.g. the original page is unavailable or is still being designed).
 +
You can redirect domain either via cPanel or via .htaccess file. This tutorial will explain how to create a domain redirect in your [http://myidealhost.com/hosting.shtml cPanel hosting] account.
  
1. Log in to your cPanel and look for the 'Redirects' icon located under the 'Domains' menu.
 
2. Choose the domain name you would like to add a redirect for from the pull-down menu.
 
3. In the 'redirects to' field, enter the URL you would like to redirect your domain to  (Note: You must specify a protocol in this field, such as http://, https://, or ftp://, e.g. http://google.com)
 
  
Options:
+
'''1'''. Log in to your '''[[cPanel]]''' and look for the 'Redirects' icon located under the ''''[[Domains]]'''' menu.
- Select whether to redirect with or without www. preceding the URL. This will allow you to redirect either www.your_domain.com or your_domain.com or both to the desired destination.
+
- Click the 'Wild Card Redirect' box if you want to redirect all files within a directory to the same filename in the new directory.
+
  
    Example: If your_domain.com redirects to your_domain1.com, then a visitor trying to access your_domain.com/somefile.html will be redirected to your_domain1.com/somefile.html.  
+
'''2'''. Choose the domain name you would like to add a redirect for from the pull-down menu.
 +
 
 +
'''3'''. In the ''''redirects to'''' field, enter the URL you would like to redirect your domain to  ('''''Note''''': You must specify a protocol in this field, such as http://, https://, or ftp://, e.g. http://google.com)
 +
 
 +
'''''Options''''':
 +
 
 +
* You can set either the '''''Temporary 302 redirect''''' or the '''''Permanent 301 redirect'''''.
 +
 
 +
* Select whether to redirect '''''with''''' or '''''without www'''''. preceding the URL. This will allow you to redirect either www.your-domain.com or your-domain.com or both to the desired destination.
 +
 
 +
* Click the ''''''Wild Card Redirect'''''' box if you want to redirect all files within a directory to the same filename in the new directory.
 +
 
 +
Example: If your-domain.com redirects to your-domain1.com,  
 +
then a visitor trying to access your-domain.com/somefile.html  
 +
will be redirected to your_domain1.com/somefile.html.</div>
 +
 
 +
{{#icon: How_to_redirect_domain_via_cPanel.png|How to redirect domain}}
 
----
 
----
<span style="color:#B0C4DE"><FONT SIZE="+1">'''Redirect in htaccess'''</FONT></span>
+
<span style="color:#B0C4DE"><FONT SIZE="+1">'''Redirect in .htaccess (http and https redirects)'''</FONT></span>
 +
 
 +
<div align="justify">The previous tutorial (see above) explaines how to set a domain redirect via '''cPanel'''. Now you'll be provided with the info needed to create http redirect with '''.htaccess file'''.
 +
 
 +
In order to set '''.htaccess redirect''' you need to access .htaccess file first. This can be done either via your '''cPanel File Manager''' or via any '''FTP''' software. .htaccess file for your main domain  is located within 'public_html' folder.
 +
 
 +
You can create both http redirect and https redirect (permanent 301 redirect) by adding the following rules to your .htaccess file.
 +
 
 +
This rule will redirect all none SSL traffic (http) to the SSL (https) portion of your site:
 +
 
 +
RewriteEngine On
 +
RewriteCond %{SERVER_PORT} !=443
 +
RewriteRule ^ https://yourdomain.com%{REQUEST_URI} [NS,R,L]
 +
 
 +
Also take into consideration that '''''www.yourdomain.com''''' is different from '''''yourdomain.com'''''. So you'll need to use one of the following rules to redirect domain visitors from one to the other.
 +
 
 +
If you have an SSL certificate installed for www.yourdomain.com you may want to redirect all yourdomain.com traffic to www.yourdomain.com.
 +
This rule will redirect domain visitors of yourdomain.com to www.yourdomain.com:
 +
 
 +
RewriteEngine on
 +
RewriteCond %{HTTP_HOST} ^yourdomain.com$
 +
RewriteCond %{REQUEST_URI} !^.*www.*$
 +
RewriteRule ^(.*)$ http://www.yourdomain.com [R=301]
 +
 
 +
If your SSL is installed for yourdomain.com you may want to redirect www.yourdomain.com to yourdomain.com.</div>
 +
This rule will help you to set redirect you need:
 +
 
 +
RewriteEngine on
 +
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
 +
RewriteRule ^(.*)$ http://yourdomain.com [R=301]
 +
 
 +
*replace yourdomain.com with the domain needed.

Latest revision as of 10:52, 26 October 2012

rss feed for my website