开发者

How to filter current url using php

Example current URL http://www.domain.com/subdomain/install/finish.php

I use this code to get the cur开发者_开发技巧rent URL.

$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

Now I want to get the URL looks like http://www.domain.com/subdomain if there don't have sub-folder it will read like http://www.domain.com

Let me know.


I don't really understand your requirement, but take a look at parse_url().

It splits a URL into the following fragments:

* scheme - http://
* host www.domain.com
* port 
* user
* pass
* path /subdomain/install/finish.php
* query  
* fragment  
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜