Choose the address with or without www and set up a 301 redirect
Set the preferred domain in Plesk, redirect a domain or a page with a 301 code and avoid redirect loops.
On this page
Your values
Enter them once and the commands in this guide update.
A site often responds at two addresses: your-domain.com and www.your-domain.com. Without a redirect, search engines may treat them as two sites and split your ranking between them.
This guide sets a single address, then presents the methods for redirecting an entire domain or a single page.
A 301 redirect announces a permanent move. Google uses it as a signal to keep the new address. A 302 redirect announces a temporary move, and the old address generally stays in the results.
Prerequisites
- Access to Plesk, see Connect to Plesk interface.
your-domain.comandwww.your-domain.compointing to your hosting, see Connect a domain registered elsewhere.- A certificate covering both addresses, see Enable a Let's Encrypt certificate.
Choose the main address
- In Websites & Domains, open your domain.
- Go to Hosting & DNS > Hosting. Depending on the view, click Hosting Settings instead.
- In Preferred domain, choose
your-domain.comorwww.your-domain.com. - Confirm with OK.
Both choices are equivalent for SEO. What matters is keeping only one. The None value turns the redirect off and is not recommended for a public site.
WordPress sites
The address configured in WordPress must match the preferred domain. Check it in Settings > General, in the WordPress Address (URL) and Site Address (URL) fields. If the two settings contradict each other, the site can end up in a redirect loop.
Check the main address
Test each variant:
curl -sI http://your-domain.com/ | grep -iE '^(HTTP|location)'
curl -sI http://www.your-domain.com/ | grep -iE '^(HTTP|location)'
curl -sI https://your-domain.com/ | grep -iE '^(HTTP|location)'
curl -sI https://www.your-domain.com/ | grep -iE '^(HTTP|location)'If you chose the address without www and forced HTTPS, the expected result is as follows:
| Address tested | Expected response |
|---|---|
http://your-domain.com/ |
301 to https://your-domain.com/ |
http://www.your-domain.com/ |
301 to an address without www or in https:// |
https://www.your-domain.com/ |
301 to https://your-domain.com/ |
https://your-domain.com/ |
200 |
All variants must end up at the same address, preferably in one or two redirects.
Choose the redirect method
| Need | Method |
|---|---|
| Send another domain to your main site | Domain alias with a 301 redirect |
| Send an entire domain to another address | Forwarding hosting type |
| Move a page or a folder | Rule in .htaccess |
Redirect another domain with an alias
- Point the other domain to your hosting.
- In Websites & Domains, run Add Domain Alias.
- Choose the main domain and enter the alias.
- Leave Web service turned on and select Redirect with the HTTP 301 code.
- Turn on Mail service only if the alias must receive email in the main domain's mailboxes.
For the redirect to work over HTTPS as well, the certificate must cover the alias. Without this 301 option, the alias behaves like a separate site for search engines.
Redirect an entire domain with the hosting type
- Open the hosting settings of the domain to redirect.
- Click Change next to Hosting type, then choose Forwarding.
- Enter the destination address.
- Choose Standard forwarding, then Moved permanently (code 301).
- Confirm.
Avoid Frame forwarding, which keeps the old address displayed in the browser. Choose Moved temporarily (code 302) for a temporary change.
Redirect a page or a folder with .htaccess
- Open Websites & Domains > your domain > File Manager.
- Go into
httpdocs, or into your site's root if it is different. - Copy the existing
.htaccessfile to keep a backup. If it does not exist, create it. - Add your rules at the top of the file. On WordPress, place them above the
# BEGIN WordPressline.
Test first with R=302, then switch to R=301 once the result is correct. Browsers remember permanent redirects, which makes corrections harder.
To redirect a page:
RewriteEngine On
RewriteRule ^old-page/?$ /new-page/ [R=301,L]To redirect a folder while keeping the rest of the address:
RewriteEngine On
RewriteRule ^old-folder/(.*)$ /new-folder/$1 [R=301,L]To redirect an old domain already attached to the same site:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://your-domain.com/$1 [R=301,L]In .htaccess, the RewriteRule pattern is written without a leading /. Then check the result:
curl -sI https://your-domain.com/old-page/ | grep -iE '^(HTTP|location)'Troubleshooting
| Symptom | Likely cause | Solution |
|---|---|---|
ERR_TOO_MANY_REDIRECTS |
Plesk, .htaccess, the CMS or a plugin apply conflicting rules |
Keep a single rule per need. To isolate the cause, temporarily set Preferred domain to None |
| The preferred domain seems to have no effect on WordPress | The site enforces its own address, or a custom rule takes priority | Align the WordPress address and check .htaccess |
www does not respond |
The www DNS record is missing |
Add it, then wait for propagation |
| Certificate warning before the redirect | The certificate does not cover the starting address | Reissue the certificate with this name |
500 error after editing .htaccess |
Syntax error in a rule | Restore your copy, then fix the rule |
The rule does not apply to a .pdf, .jpg or .html file |
nginx serves these files directly without going through Apache | Contact support to find out your hosting configuration |
No .htaccess rule applies |
The site is not processed by Apache | Contact support, because .htaccess is only read by Apache |
| The old redirect persists | The browser has remembered it | Test with curl or in private browsing, then clear the cache |