<?php$url = "http://subdomain.domain.com/sample/url"; $host = parse_url($url, PHP_URL_HOST);$host = array_reverse(explode('.', $host));$host = $host[1].'.'.$host[0];echo "$host";?>
You should know your purpose in life, make a difference, and believe in yourself. Always think positive, take the risk and move forward. Do that, then before you know it, you're already the man you always wanted. Cheers!!
<?php$url = "http://subdomain.domain.com/sample/url"; $host = parse_url($url, PHP_URL_HOST);$host = array_reverse(explode('.', $host));$host = $host[1].'.'.$host[0];echo "$host";?>
<VirtualHost>
DocumentRoot /www/subdomain
ServerName www.domain.tld
ServerAlias *.domain.tld
</VirtualHost>
RewriteCond %{ENV:REDIRECT_SUBDOMAIN} =""
RewriteCond %{HTTP_HOST} ^([a-z0-9][-a-z0-9]+)\.domain\.com\.?(:80)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.*) %1/$1 [E=SUBDOMAIN:%1,L]
RewriteRule ^ - [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN},L]