How to setup a domain forward or 301 redirect in Plesk
There are a variety of ways of redirecting visitors from one domain or page to another with 301 redirects being the style of HTTP redirect that is both user and search engine friendly. 301 redirects are a signal to search engines that a particular website or page has moved permanently to another URL. For example, if you were re-branding your old business (oldbusiness.com) to new business (newbusiness.com) you would want to forward the old domain to the new one using a 301 redirect.
For each type of redirect described in this article to work (except for a manual redirect) you must ensure that your domain name is configured to use our DNS hosting, which is included with our hosting plans, otherwise you will need to also manually create a DNS record in the control panel at your DNS hosting company.
How to create a 301 redirect
There are a number of ways that you can setup a 301 redirect, including using an .htaccess file, PHP code, JavaScript code, Perl code, etc. It’s important to recognize that in general 301 redirects can also be used to redirect individual pages and not just entire websites, however some of the methods we’re about to describe will only do so for the entire domain. Here’s all the options for creating a domain forward or redirect:
- Plesk Domain Aliasing (only forwards domain to domain, can optionally be applied to DNS, Web, and Mail)
- Plesk Domain Forwarding (can forward domain to any URL, only applies to Web)
- Plesk Subdomain Forwarding (can forward subdomain to any URL, only applies to Web)
- Redirecting any URL to any URL via custom web server directives or code (only applies to Web)
- Registrar Domain Forwarding: can forward domain to any URL, but sometimes registrars do not use proper HTTP status codes, like 301 or 307, so we don’t recommend registrar level domain forwarding unless your domain is registered with us. Only applies to Web.
Redirect with a Domain Alias
If you’re forwarding an entire domain to another (like mydomain.com to mynewdomain.com), the simplest way to do this in Plesk is to simply add it as a domain alias — Plesk will automatically ensure that it sets up a 301 redirect for you.
- Login to Plesk and choose the Add Domain Alias button
- Enter the domain you wish to forward and then select the domain you wish to forward it to
- Leave all check boxes at their defaults. If you do not wish to forward mail, un-check the “Mail Service” box.
- Choose the OK button to save your settings
Your domain -> domain redirect is now in place.
Advanced Usage Note:
If you wish to alias the DNS / Mail services, but have the domain forward to a particular page, you can disable the function “Redirect with the HTTP 301 code” and add the following code to your site’s .htaccess file:
RewriteCond %{HTTP_HOST} ^(www.)?youraliasdomain.tld [NC]
RewriteRule ^(.*)$ https://yourmaindomain.tld/location [L,R=301]
This tells the server that if the user visits the “youraliasdomain.tld”, to redirect them to the new location specifically instead of aliasing for the whole site. This is great if you use a custom domain for a landing page on your main site!
Redirect with Domain Forwarding
- If you have not yet added the domain in Plesk, login to Plesk and choose the Add Domain button, select Blank Website, and enter the domain name, then if you see the option to select the “Hosting Type”, select Forwarding. If you do not, confirm adding the domain and proceed to the next step.
- If the domain already exists in Plesk or if you did not see the option to select the “Hosting Type” in step 1, find your domain in the list in Plesk, then click “Hosting and DNS“. Then click “Hosting“. Look just below the domain name and you’ll see “Hosting Type” with a dropdown to change it. Click that dropdown and you’ll be presented with the option to select Forwarding (do that)
- Enter the destination URL
- Choose the forwarding type / response code. Be sure to select carefully. If there’s any point in the future where you may wish to remove this forward, it’s recommended to choose “Moved Temporarily,” otherwise you should choose “Moved Permanently”. Frame forwarding is typically not recommended.
- Click OK to save your settings.
Your domain -> URL redirect is now in place.
Redirect with Subdomain Forwarding
If you’d like to forward a subdomain to another URL, here’s how to do so in Plesk 11.5 and newer:
- Login to Plesk and choose the Add Subdomain button
- Enter your subdomain and leave the default settings as is.
- Press OK to create the subdomain
- Under the Subdomain’s settings, choose Hosting Settings
- Look for “Hosting type” then select the Change link beside “Website”
- In the drop down menu beside “Hosting Type” choose Forwarding
- Enter the destination address and Press OK to save the settings.
Your subdomain -> URL redirect is now in place.
Redirect with Web Server Config
nginx redirects
If you are a Plesk admin you can create an nginx redirect like this:
- Login to Plesk and choose “apache and nginx settings” under the domain you wish to add the redirect to.
- Scroll down to the “Additional nginx directives” box (this will not be visible if you are not an admin).
- Enter your choice of the following variants in the box and press Apply or OK.
# Simple path to path redirect:
rewrite ^/source_path$ https://www.destination.com/new_path permanent;
# Regex redirect to redirect *all* content from one domain to another:
rewrite ^/(.*)$ https://www.destination.com/$1 permanent;
apache and .htaccess redirects
You’ll want to set up a manual redirect in your .htaccess file if you wish to redirect one URL to another such as mydomain.com/subfolder to mydomain.com/newfolder. Many content management systems like WordPress have great plugins to make this easier to manage, although redirecting using the .htaccess file will be fractions of a second faster than using those plugins.
Feel free to use the following lines if you are setting up your own .htaccess 301 redirects. Be sure to replace ‘yournewsite.com’ with your actual new domain.
# Redirect everything: RewriteEngine on RewriteCond %{REQUEST_URI} !^.well-known/acme-challenge RewriteRule ^(.*) https://yournewsite.com$1 [R=301,L] # Redirect specific pages (use this OR the everything rule above. NOT BOTH): redirect 301 / http://yournewsite.com/ redirect 301 /oldpage/ http://yournewsite.com/newpage/ redirect 301 /oldpage.html http://yournewsite.com/newpage/
Code Redirects
You can also create your redirects in your web application’s code, like using a WordPress plugin or with raw PHP of your own. We recommend doing it this way if your site is lightweight and if you’re redirect subpage to other pages. To find out the best way to do this, do a Google search for your web application’s or programming language’s name and redirect, like ‘WordPress redirects’ or ‘PHP redirects’ and you’ll be sure to find lots of great options.
Performance Warning: Code-based redirects will be slower than the web server level redirects described above (all of the above solutions are web server level) and so if you have larger quantities of traffic expected to hit those redirects, it’s far better to use a web server based solution. If you’re hosted with us, the Plesk powered options above or custom nginx redirects will be the most performant as they are all impelemented in nginx.
Should I alias various domains for SEO benefits?
If there’s no site hosted directly at the address, the address isn’t gaining any SEO benefit. For example:
- MAINDOMAIN.TLD – This is your main site
- HEY-LOOK-I-GOT-A-KEYWORD.TLD – this is your ‘seo domain’
HEY-LOOK-I-GOT-A-KEYWORD.TLD
forwards (301 redirect) to your main domain, Google doesn’t even pay attention to it’s existence, it only sees the destination.
However, if you have an optimized and informational landing page (with content!) at HEY-LOOK-I-GOT-A-KEYWORD.TLD
and it has links going to MAINDOMAIN.TLD
, it will get benefit from its keywords AND pass some benefit on to the destination page.
Therefore the primary reason to get multiple domains for the same site is to prevent typosquatting. For example, if you own DOMAINA.TLD
, one could argue that it’s important to own:
- DOMAINA.TL
- DOMAIN-A.TLD
- DOMAINAS.TLD
Not for any SEO benefit, but so nobody else sidelines your business on a very similar domain. More details in our article on owning keyword domains here.
If you’re not hosted with us, consider moving on over! Check out our shared hosting or Plesk VPS hosting options.
Posted in Advanced, Client Centre & Plesk
About Websavers
Websavers provides web services like Canadian WordPress Hosting and VPS Hosting to customers all over the globe, from hometown Halifax, CA to Auckland, NZ.
If this article helped you, our web services surely will as well! We might just be the perfect fit for you.