• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Resolved Single redirect of non-www to www through https/ssl (redirect all to https://www.*)

Shawn

New Pleskian
I am trying to create single redirects for variations of my webpage.

For example:

example.com
www.example.com
https://example.com

Each uses a single redirect to https://www.example.com

I went to Websites & Domains --> Apache & nginx Settings

For "Additional directives for HTTP" I added the following:
Code:
ServerName example.com
ServerAlias www.example.com
Redirect 301 / https://www.example.com/

So far it is working as all http:// requests are sent to https://www.example.com/

However, what configuration do I need for "Additional directives for HTTPS" so that https://example.com is sent to https://www.example.com?


PS nginx settings are Proxy mode
 
Here is an example of my redirects before Subscriptions > Your subscription > Hosting Settings > Preferred domain > Choose the "www.*" option.



Here is an example of my redirects after the "www.*" option.



I used this tool here to test redirects: https://varvy.com/tools/redirects/

As you can see, choosing the "www.*" option solves one problem. That is it redirects https://example.com to https://www.example.com

However, this option also creates two redirects for http://example.com to https://www.example.com.

I came across "additional directives for http" and "additional directives for https" and think if I set this up correctly it might work. Currently with the setup I described in the first post, there is only one redirect from http://example.com to https://www.example.com

I would like single redirects and need a configuration to redirect https://example.com to https://www.example.com
 
Last edited:
No, it does not. It only redirects from the non-www to the www version. The redirect from the non-SSL to SSL comes from another directive or setting. That is also the reason why more than one redirect is happening.

Exactly. My first http directive is causing the following chain when that setting is enabled:
http://example.com to https://example.com to https://www.example.com

I need one redirect for all variations of URL to www. + SSL (https://www.*)

My current setup redirects http://example.com and http://www.example.com to https://www.example.com (with the http directive via one redirect).

However, I need a unique directive to send https://example.com to https://www.example.com
 
Last edited:
I see what you want. I didn't get it from your initial post. You want something like

<If "%{HTTP_HOST} != 'www.example.com' || %{SERVER_PROTOCOL} != 'HTTPS'">
Redirect "/" "https://www.example.com/"
</If>

Have you tried that? It should redirect anything to https://www in one request. I've never combined two conditions in a single statement. According to Apache the Backus-Naur notation can be used, but not sure if this will really work. It needs at least Apache 2.4.
 
I found a solution. It is all being configured with VirtualHost. One for port 80 and one for port 443 (one for SSL and one for non-SSL)

To enable a Single Redirect for all variations of a website to https://www.* the following settings should be applied in "Websites and Domains" --> "Apache & nginx Settings"

Additional directives for HTTP:

Code:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com$1 [R=301,L]

Additional directives for HTTPS:

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule (.*) https://www.example.com$1 [R=301,L]
 
Hello,
I have the same issue on one website (wordpress) and followed your suggestion, but it did not work. In fact, I am using "none" in Plesk subscription hosting settings (but https://www... in wordpress settings) and already everything is redirected except for the home page.

With or without the additinal http and https directives makes no difference.
I also have a www CNAME record correctly pointing to main domain.

Other cases configured the same way work fine.

My config is nginx with PHP-FPM; Plesk is 17.8.11 Update #61

Any hint, please?

Best regards

Franco
 
Back
Top