Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should PHP header locations be encoded?

Should PHP header locations be encoded?

header("Location: ".$_SERVER["REQUEST_URI"]);
header("Location: ".rawurlencode($_SERVER["REQUEST_URI"]));

If so, why, when, and how?

like image 621
user1032531 Avatar asked Nov 10 '22 03:11

user1032531


1 Answers

You only need to encode it, if you have some special chars (defined in RFC1806) in your URL. Especially you should encode all URLs with the following characters: {}|\^~[]` (as of RFC1738)

like image 170
Cheesi Avatar answered Nov 12 '22 19:11

Cheesi