The internal PHP function "parse_url" is not always sufficient to parse URLs or URIs correctly into their components, such as Host/Domain, Path, Segments, Query and Fragment.
In this case you need a reliable result array like this:
- [SCHEME] => http
- [AUTHORITY] =>
user:[email protected]:80
- [USERINFO] => user:pass
- [USER] => user
- [PASS] => pass
- [HOST] => www.domain.com
- [REGNAME] => www.domain.com
- [DOMAIN] => www.domain.com
- [LABEL][] =>
- [LABEL][] => com
- [LABEL][] => domain
- [LABEL][] => www
- [PORT] => 80
- [PATH] => /dir1/dir2/page.html
- [SEGMENT][] => dir1
- [SEGMENT][] => dir2
- [SEGMENT][] => page.html
- [QUERY] => key1=value1&key2=value2
- [GET][key1] => value1
- [GET][key2] => value2
- [FRAGMENT] => anchor/line
- [ANCHOR][] => anchor
- [ANCHOR][] => line
There's a standard-compliant, robust and performant PHP Class for handling and parsing URLs / URIs according to RFC 3986 and RFC 3987 available for download and free use:
http://andreas-hahn.com/en/parse-url