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

  1. 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”:
    domain alias - hosting settings
  2. Deselect the 301 redirect, which is the default for an alias: 
    plesk domain alias - deselect 301 redirect
  3. Click OK to apply.
  4. Next, create a file called .htaccess either in the httpdocs of your website or on your local machine to FTP. 
  5. 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]
    

    Tip: The caret ^ denotes the start of a match and the dollar sign $ denotes the end of a match.

  6. 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.
  7. 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.

Hint: Browsers can cache old redirects, so ensure you open a new incognito tab (which bypasses existing cached calls) within your browser to test.

Was this article helpful?

Related Articles