DevHeads.net

ErrorDocument with URL containing URL encoded chars

Hello List,

have a interesting problem here.
I have a .htaccess with Errordocument containing Text to be displayed:

ErrorDocument 404 "not existing"

This works with standard URLs like <a href="http://example.com/fubar.htm" title="http://example.com/fubar.htm">http://example.com/fubar.htm</a>
I get response 404 and in Browser displayed text is correct.

Now i try URLs like this: <a href="http://example.com/%2ffubar" title="http://example.com/%2ffubar">http://example.com/%2ffubar</a>
The URL encoded part of URL seems to be a problem for errordocument. I
still get the 404 respone, but displayed text has changed.
In place of "not existing" apache answers with "The requested URL
//fubar was not found on this server."
So apache is decoding $2f to / and use decoded URL for response-text in
place of "not existing"

i get a change of behaviour if i put the ErrorDocument directive direct
into Vhost instead of .htaccess.
in this case the ErrorDocument is working as expected also with URLs
with url encoded Parts.

In Apache 2.2 and 2.4  is same behaviour.
What is problem here and how to solve this?

Thanks,
Hajo

Comments

Re: ErrorDocument with URL containing URL encoded

By Dan Ehrlich at 01/09/2019 - 03:58

Not surprising that you got different behavior after removing a value from
.htaccess and placing it elsewhere.

No one knows exactly / 100% how .htaccess works. The file only exists
because they wanted to maintain backwards compatibility with the web server
that used to come with Mosaic at University of Illinois in the mid-90's.
That server, called NCSA, had a requirement for directory level config
files.

Funny enough this is where the name Apache comes from...it was basically a
collection of patches / a very "patchy" together web server

Sorry I couldn't be of more help:

<a href="https://en.wikipedia.org/wiki/NCSA_HTTPd" title="https://en.wikipedia.org/wiki/NCSA_HTTPd">https://en.wikipedia.org/wiki/NCSA_HTTPd</a>

<a href="https://www.askapache.com/htaccess/" title="https://www.askapache.com/htaccess/">https://www.askapache.com/htaccess/</a>