How to filter current url using php

Posted by bob on Stack Overflow See other posts from Stack Overflow or by bob
Published on 2010-05-09T07:10:09Z Indexed on 2010/05/09 7:18 UTC
Read the original article Hit count: 230

Filed under:
|

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

I use this code to get the current 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.

© Stack Overflow or respective owner

Related posts about php

Related posts about url