• 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

wildcard virtual subdomain and...

saatchi

Basic Pleskian
Hello,

I search my problem and I couldn't find & solve it. I think that it's a public problem for who wants to make virtual sub-domains.

I want to redirect my non-exist subdomains to my main site with its parameters like this :

nonexist.mydomain.com -> mydomain.com/?name=nonexist

To make virtual subdomain,
1- I added an A record: * A my-ip-address
2- After that, I added "ServerAlias *.mydomain.com" into conf/vhost.conf

After this, my non-exist subdomains are working but they will open Apache's default page. How can I set that I want to open my main site.
 
You can do this for all domains, or just one domain like this

DOMAINS=$(mysql -uadmin -p`cat /etc/psa/.psa.shadow ` psa -Ne "select Name from domains;")
for DOMAIN in $DOMAINS ; do # ALL DOMAINS
for DOMAIN in `echo domain1.com domain2.com` ; do #Just these 2 domains
echo "ServerAlias *.$DOMAIN" >> /var/www/vhosts/$DOMAIN/conf/vhost.conf;
echo "ServerAlias *.$DOMAIN" >> /var/www/vhosts/$DOMAIN/conf/vhost_ssl.conf;
/usr/local/psa/admin/bin/websrvmng -u --vhost-name=$DOMAIN
done

/usr/local/psa/admin/sbin/websrvmng -va

That will redirect all sub domains to your main domain, then on your main domain you can safely say since the host is a sub domain and your on the main domains page, the sub domain doesnt exist, so then use an .htaccess to mod_rewrite the url
 
Hello Everyone,

I´m trying to setup a virtual subdomains to the users in my website. Like user john signs up and is given a subdomain to access his account, john.website.com, which when rendered in the browser will automatically bring up http://website.com/shop/john.html username=john or similar

Is there Anyone can help me with it?
 
Very uncomfortable

The problem with Plesk & virtual hosts is even worse.

Instead of having to write ServerAlias *.domain.tld Plesk writes in every generated **httpd.include:
ServerAlias www.domain.tld
ServerAlias ipv4.domain.tld
Еven for subdomains it writes:
By the way, Parallels personally don't use www.forum.parallels.com
Do you know anyone who uses? O_O

1. What this "www" is using for? And especially for subdomains?
2. Is not easier to use ServerAlias *.domain.tld onse? No one need neither "www" nor "ipv4" in this way.
3. Which address redirects non-exist subdomains if several Webspaces uses one shared IP? To another Webspace!

Namely, I have several Webspaces in Plesk, some with shared IP, with several different domains & subdomains on each, so if on a Webspace #2 let us say subdomain blabla.apple.com don't exists then Apache redirects visitors to the domain let us say www.[B][I]microsoft.com[/I][/B] on Webspace #1 - not just because they shares one ip but because Plesk loves aliases www.domain.tld only.

I was forced to add ServerAlias *.domain.tld manually in every **httpd.include generated by Plesk and remove useless www.sub.domain.tld && www.domain.tld. After all redirects works ok, but I think Plesk can overwrite my files with their "www" again at any time (I hope without "http://", you never know..) so I think this must be corrected by developers as soon as possible.

Btw, why not to add in Plesk DNS template a record with *.domain.tld by default?
 
Last edited by a moderator:
Back
Top