How to get current page URL for multisite wordpress deployment
I'm trying to find the URL of the current page on wordpress. I have been using this so far -
$cur_page_url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
But this doesn't work in a multisite deployment where the website address is like site1.example.com
. In such a case, $_SERVER['SERVER_NAME']
returns example.com
instead of site1.example.com
.
What shoul开发者_JAVA技巧d I use to get correct page URL?
you can use HTTP_HOST
instead of SERVER_NAME
$_SERVER['HTTP_HOST']
精彩评论