Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 views
in Technique[技术] by (71.8m points)

php - Get current domain

I have my site on the server http://www.myserver.uk.com.

On this server I have two domains:

one.com and two.com

I would like to get the current domain using PHP, but if I use $_SERVER['HTTP_HOST'] then it is showing me

myserver.uk.com

instead of:

one.com or two.com

How can I get the domain, and not the server name?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try using this:

$_SERVER['SERVER_NAME']

Or parse:

$_SERVER['REQUEST_URI']

Reference: apache_request_headers()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...