开发者

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']
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜