• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Redirect root domain and all wildcard subdomains to specific subdomain

molmagman

New Pleskian
Here is my problem.

Say I have a domain bestwebsite.com but I want all traffic to redirect to the.bestwebsite.com, even from the root domain. This is the company name.
I have set up one subscription for bestwebsite.com with a wildcard SSL certificate.
I can make bestwebsite.com redirect to the.bestwebsite.com using the following .htaccess file...

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^the\.bestwebsite\.com$ [NC]
RewriteRule ^(.*)$ https://the.bestwebsite.com/$1 [R=301,L]

...but my site is hosted in a subscription for bestwebsite.com so the.bestwebsite.com is not found and redirection from anything other than the root domain does nothing :(

BTW - bestwebsite.com is not my real domain :)

I'm using Plesk Obsidian on a VPS from IONOS but I have access to the DNS settings and file system.
 
Maybe the Rewrite is unnecessarily difficult for what you wish to achieve. You could put
Code:
Rewrite 301 / https://the.bestwebsite.com/
into your .htaccess file to redirect all.
 
Maybe the Rewrite is unnecessarily difficult for what you wish to achieve. You could put
Code:
Rewrite 301 / https://the.bestwebsite.com/
into your .htaccess file to redirect all.
Wouldn't that result in a redirect loop?
 
When the user puts the code into his main domain, it will simply redirect to the subdomain. The subdomain is not affected by it. Unless however, the user has created the document root directories of his subdomain branching off the document root directory of his main domain. But the default configuration is that each domain and subdomain has their own subdirectory branching off the user's home.
 
Back
Top