The current URL is
https://a.example.com/
Also
https://b.example.com/
If so, how do I get example.com?
Can't I get it from the predefined variable $_SERVER?
php
There seems to be a package called PHP Domain Parser.
how-to examples:
Separate domain names from subdomains in PHP - Qiita
$pslManager=new Pdp\PublicSuffixListManager();
$parser = new Pdp\Parser($pslManager->getList());
$url='www.domainname.net';
$subdomain=$parser->getSubdomain($url);
$domainName=$parser->getRegisterableDomain($url);
/** $subdomain='www'*/
/** $domainName='domainname.net'*/
© 2024 OneMinuteCode. All rights reserved.