Page 1 of 1

Simple URL Parser

Posted: Tue Feb 17, 2009 8:26 pm
by LanceEh
Ok, I was running into a problem with a URL in a dynamic site because the links were registering wrong when trying $_SERVER['PHP_SELF'] $_SERVER['REQUEST_URI'] and $_SERVER['SCRIPT_NAME'] due to Mod_Rewrite, so I had to manually strip the URL using.

$url=parse_url($_SERVER['PHP_SELF'],PHP_URL_QUERY);

Which has worked so far.

P.S. ['PHP_SELF'] worked until a variable was appended to the end, then it kept adding variables, (rather than the URL without the variables). Oh well, it works now unless someone else has a better solution.

Take care.

Re: Simple URL Parser

Posted: Wed Feb 18, 2009 10:26 am
by pickle
Don't use PHP_SELF - it's not guaranteed to be set. Use REQUEST_URI instead.

Re: Simple URL Parser

Posted: Sat Feb 21, 2009 10:19 pm
by LanceEh
ok, thanks. Don't think that code was working anyway.

Re: Simple URL Parser

Posted: Sun Feb 22, 2009 5:38 am
by semlar
Maybe this could be fixed by adjusting your rewriterule.