简体   繁体   English

WordPress获取永久链接不会按原样获取URL

[英]WordPress Get Permalink Doesn't Get URL 'As Is'

I'm using the function get_permalink() to try and get the Current URL. 我正在使用get_permalink()函数尝试获取当前URL。

I've noticed it doesn't actually get the exact URL as shown in the address bar, for example if it is formatted like: 我注意到它实际上并没有获得地址栏中显示的确切 URL,例如,其格式如下:

domain.com?s=one&two&three=0&four= domain.com?s=一&二&三=三&四=

Is there a function to get the exact current URL? 是否有获取确切当前URL的功能?

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on")     {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".    $_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].    $_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM