Wildcard subdomain

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
NamecheapNamecheap
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
0
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back