Capturing domain name

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

Name Trader

formerly @stubTop Member
Impact
11,469
I would like to have a For Sale page with many domains being redirected to that page. Is there any way to capture the domain name in a variable so I can display it on the served page.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
<?php echo $_SERVER['SERVER_NAME'] ?>

edit: wait, sorry, you want to redirect them all to the same url, using forwarding?

e.g.

domain1.com -> domainforsale.com
domain2.com -> domainforsale.com

probably the most reliable way would be to include the domain in the url, e.g.

domain1.com -> domainforsale.com?domain=domain1.com
domain2.com -> domainforsale.com?domain=domain2.com

then you have $_GET['domain']

if you dont want to do that, you might be able to use the referrer property, however there is no guarantee it will always exist.

$_SERVER['HTTP_REFERER']
 
Last edited:
0
Close
Last edited:
0
Close
<?php echo $_GET['domain']; ?>
 
0
Close
Fabulous! I've been working on this on-and-off for about six months! Thank you very much indeed. If I could find out how to add rep, I would.
 
0
Close
lol! no problem. to add rep, you click the blue scales* icon on the left of a post, right next to the warning sign icon for reporting posts.

*i don't think it looks like scales at all

p.s. the code i gave you is really just an example, is insecure, allows anyone to put whatever they want into the address bar of their browser and have your site render it, this means they could put some nasty javascript or frame code in some links to your site.

this is much more secure:

<?php
echo preg_replace('/[^a-zA-Z0-9.-]/', '', $_GET['domain']);
?>

( only allows numbers, letters, dots and hyphens )
 
Last edited:
1
Close
Funny. I knew it was somewhere down there, and I tried clicking on a few things (but I think I might have been right-clicking). Rep added. I think it looks like gray scales :)

Thank you for the revised code.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back