当前页面的url,没有页面名称和查询字符串 [英] url of the current page without page name and query string
本文介绍了当前页面的url,没有页面名称和查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如问题中提到的,我想获取没有页面名称和查询字符串的页面的 url.
As mentioned in the question, I want to get the url of the page without the page name and query string.
例如我的网址是:
http://sub.domain.com/app/page.php?var=abc
我想要的是:
http://sub.domain.com/app/
没有查询字符串和页面名称.
what I want from this is:
http://sub.domain.com/app/
without the query string and page name.
我找到了这个教程:
http://www.phpf1.com/tutorial/get-current-page-url.html
这很有帮助,但不是我想要的.
I found this tutorials:
http://www.phpf1.com/tutorial/get-current-page-url.html
it was helpful but not exactly what I want.
感谢您的回答.
推荐答案
我建议使用以下技巧:
$location = dirname(__FILE__);
如果您需要绝对网址,请在其前面添加以下内容:
If you need an absolute URL, add the following in front of it:
$protocol = 'http'.(!empty($_SERVER['HTTPS']) ? 's' : '');
$root = $protocol.'://'.$_SERVER['SERVER_NAME'];
这篇关于当前页面的url,没有页面名称和查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文