Issue Forwarding to WWW

tescik tescikowski

New Pleskian
Server operating system version
Debian 12
Plesk version and microupdate number
18.0.77 Update #2
I set up hosting for my client using the “Forwarding (Moved permanently (code 301))” hosting type.
My client wants the redirect target to be the “www” subdomain for the same domain.
For example:
mydomain.com > http://www.mydomain.com/path/to/file.html
Subdomain www.mydomain.com is a CNAME record that points to the external domain outdomain.org.
When I try to set this target, I get the following error:
Error: An invalid URL was requested.
Or
Redirect address cannot be set to a domain name.
I suspect this is related to the hard-coded association between the domain and www.
In Hosting Types: Website Hosting, you can set Preferred domain to None. Is there a similar option for Hosting Types: Forwarding? Or is there another workaround for my issue with a single domain?
The only solution I came up with is to create a web hosting account and set up a redirect using an .htaccess file.
But I create the forwarding service using an API, and I’d prefer not to introduce exceptions into the automated creation process and keep the forwarding as is.
OS: Debian 12
Plesk Obsidian 18.0.77 Update #2 Web Host Edition (an update to 18.0.78 is coming in two weeks, but I don’t think the version is the issue here)
 
So usually the www subdomain is associated with the main domain, that's how it's been since the dawn of the internet before people started to drop the www part but most people keeps the www as an alias to the main domain for backwards compatibility. Plesk, by default, reserves the www for the main domain for this reason (although I do believe there were talks about removing this limit so you could in the future create the www subdomain in the future so you can have it do other things but don't think that went anywhere at the current moment).

As a work around you could try is to set the site to use Website Hosting instead of forwarding, set the preferred domain to None, then you can try adding the following for the .htaccess
Apache config:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/path/to/file.html [L,R=301]

(or something like that)

This could probably work but you'll need to test and such.
 
Back
Top