Setup Website and URL forwarding
URL redirection or URL forwarding is a system that directs one domain name to another. For example, when visitors type in wikipedia.com or wikipedia.net, they are automatically redirected to wikipedia.org.
URL redirection can be used for URL shortening, to prevent broken links when web pages are moved to allow multiple domain names belonging to the same owner to refer to a single web site.
Below are instructions on how users can redirect their domain name or specific pages within their website to another URL. There are several different methods you can use to achieve this based on what kind of hosting you have. Please select the kind of hosting you have:
URL redirection for cPanel hosting
- Log into cPanel
- Click on the Redirects icon
- Select the domain as well as file or path you wish to redirect from
- Type in the URL that you wish to redirect to
- Select from the available parameters
- Click Add
URL redirection using website code for Cloud hosting services
If you have a web hosting space for your domain name, there are a number of different methods of URL redirection that you can use.
Note: If you have a cloud hosting service with Melbourne IT and wish to redirect to another domain name you will need to use coding to achieve this.
Using website code, website developers are able to redirect specific pages or entire websites from one URL to another. Below are examples of code that can be used to perform 301 redirections from one URL to another.
301 redirect using ASP.NET
Create a .aspx file (example: index.aspx) and add in the code below. When this is added to your website, any visitors to that file will be redirected to the URL that is entered into the code below.
301 redirect using PHP
Create a .htaccess file (example: index.htaccess) and add the code below. When this is added to your website, any visitors to that file will be redirected to the URL that is entered into the code below.
_Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
301 redirect using .htaccess
Create a .htaccess file with the below code.
_RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Place the .htaccess file into your root directory. The above code will redirect all visitors to the site where the .htaccess exists to the new URL you enter into the .htaccess file.
Redirect non-www to www via .htacess
Create a .htaccess file with the below code and change yourdomain.com to your domain name
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*) http://www.yourdomain.com/$1 [R=301,L]
Place the .htaccess file into your root directory. The above code will redirect your domain to its www record.
Updated 23 days ago