I'm trying to find the absolutely most efficient way to get /folder/subfolder/filename.php?id=1000 from http://www.website.com/folder/subfolder/filename.php?id=1000 It should also work if the "www" is not specified in the URL or if it's "https://". I searched and found this page: http://forums.digitalpoint.com/showthread.php?t=190219 , but it's doing just the exact opposite of what I'm trying to do. Thanks!