How To Do a Website Redirect
Website Redirect, also called Website Forwarding, allows you to divert traffic from one domain name to another. For example, if you enter mydomain2.com in a browser, it will automatically route visitors to mydomain1.com. This makes it possible to have multiple domains while maintaining one working website.
If you have a web hosting plan with us, you can set up a website redirect using these methods. Click the links below to go to each section:
Domain Alias
A Domain Alias or (Parked Domain) is a redirect that pulls up your main domain’s website without changing the URL. For example, if mydomain2.com is set as a Domain Alias, visitors will see the content of mydomain1.com but the URL in the browser will remain mydomain2.com.
Refer to our How To Create Domain Alias guide for more details.
301 or 302 Redirect
Compared to Domain Aliases, a 301 or 302 Redirect is better because it is a process that search engines (like Google) understand and will, therefore, affect your website ranking.
- A 301 Redirect is for permanent redirection and it tells search engines to permanently overwrite all previous copies they’ve made of your website pages and associate them with your new domain name or URL.
- A 302 Redirect is for temporary redirection and search engines will understand that you are routing your website visitors to a different site temporarily, maybe due to your original website undergoing some updates. This will preserve your original website’s ranking in search engines.
NOTE. If the domain that you wish to redirect is not the main domain connected to your Vodien hosting service, make sure to add the domain as an Addon or Parked Domain, first.
Create a 301/302 Redirect through your cPanel using these steps:
- Log in to the cPanel using this link format: http://yourdomain.com/cpanel/ (Replace yourdomain.com with the main domain name connected to your hosting.
- Scroll down to the Domains section and click Redirects.
- Under Type, select Permanent (301) or Temporary (302), then choose the domain you want to redirect from the drop-down list.
- In the box beside [/], you can enter the specific subdirectory that you wish to redirect. Or, you can leave this blank.
- Under Redirects to, enter the URL for the website that you wish to display when the domain name set above is entered.
- Redirect with or without www is ticked by default. You may change this as preferred.
- Once done, click Add.
You will be routed to the confirmation page. Click Go Back and scroll down to view all your active redirects.
HTML Code
To use this option, you will need to create an index.html file within your File Manager and add either of these code formats (remember to replace yourdomainname.com with the target URL):
Option 1:
<html>
<head>
<meta http-equiv=”Refresh” content=”7; url=//www.yourdomainname.com/” />
</head>
<body>
<p>Please follow <a href=”//www.yourdomainname.com/”>this link</a>.</p>
</body>
</html>
Option 2:
<html>
<head>
<title>Type Your Title Here</title>
<meta http-equiv = “refresh” content = “2; url = http://www.yourdomainname.com/” />
</head>
<body>
<p>Sample Introduction Here</p>
</body>
</html>
To create an index.html file, follow the steps below:
- Log in to the cPanel using this link format: http://yourdomain.com/cpanel/ (Replace yourdomain.com with the main domain connected to your hosting).
- Under the Files panel, click File Manager.
- Click public_html from the left-side menu.
- Click the +File option at the top-left section of the page.
- Under New File Name, enter index.html and ensure that /public_html is set as the destination folder in the field below it.
- Click Create New File.
- Look for the index.html file and click on it, then click Edit at the top menu.
- Paste the chosen code format in the editor and replace the URL with the website that you wish to display.
- Click on the Save Changes button at the top-right section of the editor.
Use the same steps to create an index.php and .htaccess file for the next Website Redirect options.
PHP Code
To use this option, you will need to create an index.php file within your File Manager and add the code format below:
<?php
header(“Location: http://www.yourdomainname.com/”);
/*exit;*/
?>
To create an index.php file, follow the steps for creating an index.html file.
HTACCESS Code
Rewrite the request that comes to your host server by creating a .htaccess file in your File Manager. You can use the code format below:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yournewdomainname.net [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yournewdomainname.net [NC]
RewriteRule ^(.*)$ http://yourdomainname.com/ [L,R=301,NC]
To create a .htaccess file, follow the steps for creating an index.html file.
If you have any questions, feel free to reach out to our support team for further assistance.