Lets say I have the following: Current URL: http://www.domain.com/page.php?action=list <http://www.domain.com/page.php?action=list&top=/page.php?action=list&id=3> &top=/page.php?action=list&id=3 $top = $_SERVER['PHP_SELF'].'?'.$_SERVER['argv']['0'] Now I want to create a URL with a return link in it <a href="'.$_SERVER['PHP_SELF'].'?action=add&return='.$top.'"> Add Something </a> Should I use htmlentites on $top first? Second let's say instead of constructing a link I want to use a header and redirect someone header("location: page.php?action=add&return=".$top ); So do I use urlencode here? Lets say I have something that has been htmlentitied, and I want to use a header command, do I htmlentitydecode and then urlencode?