Свойства URL

// http://example.com/page/12/?show=1#id12

location.href;     // http://example.com/page/12?show=1#12
location.pathname; // /page/12/
location.host;     // example.com
location.hostname; // example.com
location.hash;     // #id12
location.origin;   // http://example.com/
location.protocol; // http:
location.search;   // ?id=test

PHP JavaScript