• The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • Debian 11 has reached its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.81 is the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

How do I redirect all subdomains to main domain ?

N

Neantis

Guest
Hello,

I manage a server for a small association, and for their new website based on a complex dymaic back end they want to redirect all requests on subdomains to the main domain. First, I thought I can add a virtual host, but I tried and I failed. So, can you describe me how to redirect all subdomains to main domain ? ( (.+)\.domain\.com$ => domain.com?sub=$1 )

Thank you.

PS: Sorry for my english, I'm french and I haven't seen any quality forum about plesk in my language.
 
You'll need a wildcard DNS A record that maps *.example.com to the IP address of the main domain. Also setup a ServerAlias for the domain (see Including Directives into Web Server Configuration File):

Code:
ServerAlias *.example.com

When this is set up all subdomains will just hit the files on the main domain.

Then you can for instance set up a mod_rewrite rule or use some script to decide what to do depending on which subdomain was requested.
 
This doesn't work :/
What I need to add in my domain /conf/vhost.conf ?

I have tried this :
<VirtualHost 127.0.0.1:80>
ServerName mydomain.com:80
ServerAlias *.mydomain.com
</VirtualHost>
With this command after :
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=mydomain.com
And I have a PleskFatalException which explain that Plesk can't restart apache.

I have added the DNS record before doing all that.

(I have changed domain and IP here, but in the reality I have entered the right data.)
 
Back
Top