NameSilo

Wildcard subdomain

SpaceshipSpaceship
Watch

armstrong

Man from ManilaVIP Member
Impact
53
I defined a wildcard host record ( *.mydomain.com ) in enom, so if anyone types gibberish.mydomain.com then it still ends up at mydomain.com . Is there any way to capture which particular gibberish was used, perhaps through an environment variable? Can I, for example, capture this in php, and display something like:

"You entered gibberish.mydomain.com"

Thanks!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
The domain name is passed in the $_SERVER['HTTP_HOST']; (or $HTTP_HOST) variable in PHP.

If you visited http://gibberish.mydomain.com, $HTTP_HOST would equal 'gibberish.mydomain.com'

You could use a function like this to extract the first part,
PHP:
  $dots = explode('.', $HTTP_SERVER_VARS["HTTP_HOST"]); 
  unset($dots[count($dots) - 1]); 
  unset($dots[count($dots) - 1]); 
$subdomain= implode('.', $dots);
there are other ways to do the same with PHP string functions.
 
0
•••
0
•••
All this talk about the pro.ph project is getting me excited to see how it all comes together! So does php code like "explode" and "implode", but not nearly as much so... :) I can't wait for pro.ph to launch! :)
 
0
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back