Urlencode Slash 404 Error

http://localhost/foo/profile/%26lt%3Bi%26gt%3Bmarco%26lt%3B%2Fi%26gt%3B 

The above code gives me 404 Error , URL code: urlencode(htmlspecialchars($foo)); as for $foo : <i>badhtml</i>

The URL works fine when there is no need to encode, for example. marco .

Thanks. = D

Update: I have to grab a segment in the encoded part of the uri, so 404 should not appear.

There is no document there, marco is just the line I need to get this information from db. If the user does not exist, he will not throw this ugly error.

It is not clear what is wrong: I found out that if I used <i>badhtml<i> it works fine, but <i>badhtml</i> will not, what am I doing to support / in <i> ?

He probably considers the request http://localhost/foo/profile/<i>badhtml<**/**i>

+4
source share
3 answers

Since there is a slash / in the parameter, this is interpreted as a path name delimiter.

So the solution is to replace all occurrences of the slash with something that is not interpreted as a delimiter. \u2044 or something like that. And when you read the parameter again, change all \u2044 to normal slashes.

(I chose \u2044 because this character looks great like a normal slash, but you can use anything that never happens in a parameter, of course.)

+2
source

Most likely, the regular expression responsible for handling URL rewriting is not like some URL encoded characters. This is most likely a httpd / apache issue, not PHP. It’s best to start by looking for .htaccess (a file containing URL rewriting rules).

This question assumes that you are trying to pass an argument through a URL, rather than accessing a file named <i>badhtml</i> .

+1
source

Mr. Lister, you rocked.

"So the solution is to replace all the slash occurrences with something that is not interpreted as a delimiter. \ U2044 or something like that. And when you read this option again, change all \ u2044s to normal slashes."

-1
source

All Articles