Overview
If you’ve added a domain alias to redirect an existing domain to your main website, by default it will redirect all calls (via an SEO friendly 301) back to the same path on your new site. For example, if your old URL was www.oldsite.com.au/about-us/, this will automatically redirect to www.newsite.com.au/about-us. This is perfect if your old site and new site have similar or the same URL structures, however if they vary (eg /about-us/ needs to become /aboutus/) then you’ll need specific rewrites from the old site to the new site.
The Apache Web Server uses a file called a .htaccess file to achieve this without having to edit the main configuration files. To implement a redirect from an old site to a new site, you can create a .htaccess file using a text editor on your computer and upload it to the web site or use the Plesk File Manager to edit directly.
Instructions
- Any existing 301 redirects need to be removed first, otherwise they’ll override any additional rule we add. To do this, select the domain alias (if it has already been added), then choose “Hosting Settings”:
- Deselect the 301 redirect, which is the default for an alias:
- Click OK to apply.
- Next, create a file called .htaccess either in the httpdocs of your website or on your local machine to FTP.
- Add the following:
RewriteEngine on RewriteCond %{HTTP_HOST} ^oldsite.com.au [NC] RewriteRule ^about-us$ https://www.newsite.com.au/aboutus/ [R=301,L] RewriteCond %{HTTP_HOST} ^oldsite.com.au [NC] RewriteRule ^products/123$ https://www.newsite.com.au/systems/whizbangproduct/ [R=301,L] RewriteCond %{HTTP_HOST} ^oldsite.com.au [NC] RewriteRule ^products/1234$ https://www.newsite.com.au/systems/productnumbertwo/ [R=301,L] RewriteCond %{HTTP_HOST} ^oldsite.com.au [NC] RewriteRule ^(.*)$ https://www.newsite.com.au/$1 [L,R=301]
- You can create as many rewrites as required for each specific URL which needs to be changed, remembering that the RewriteCond statement is required for each. The final rewrite rule (^(.*)$) will match all other URL’s to redirect.
- If you have created this within the httpdocs directory, these changes will become available immediately. If you’ve created the file on your local machine first, transfer the file via FTP to the new server.