httpd icon indicating copy to clipboard operation
httpd copied to clipboard

autoindex does not generate trailing "/" in URLs for directories

Open hb9cwp opened this issue 9 years ago • 1 comments

httpd in OpenBSD 5.7 with "directory auto index" generates trailing slashes "/" in the HTML text output ">brA/", but not in the corresponding URLs (href="brA"), see example page below: ... <a href="brA">brA/</a> 02-Mar-2008 16:15 - ...

When the user clicks on those relative URLs, browsers attempt to fetch files, instead of directories. httpd responds with 301 Moved Permanently and redirect browsers to http://site.com/pfstat/brA/.

If auto index would append trailing slashes also to the URL, then that would save such redirects (actually two redirects when using SSL with HSTS, the first is a 301 to http://site.com/pfstat/brA/, and then second a 307 to https://site.com/pfstat/brA/).

Is this correct by design, or an oversight/bug?

<!DOCTYPE html>
<html>
<head>
<title>Index of /pfstat/</title>
<style type="text/css"><!--
body { background-color: white; color: black; font-family: sans-serif; }
hr { border: 0; border-bottom: 1px dashed; }

--></style>
</head>
<body>
<h1>Index of /pfstat/</h1>
<hr>
<pre>
<a href="..">../</a>                                                07-Oct-2015 16:26                   -
<a href="brA">brA/</a>                                               02-Mar-2008 16:15                   -
<a href="brB">brB/</a>                                               13-Apr-2008 10:35                   -
<a href="fwA">fwA/</a>                                               02-Mar-2008 15:50                   -
<a href="fwB">fwB/</a>                                               13-Apr-2008 10:35                   -
</pre>
<hr>
</body>
</html>

hb9cwp avatar Oct 10 '15 12:10 hb9cwp

I think this has already been fixed 2015-04-25 (just past the 5.7 tag).

http://bxr.su/OpenBSD/usr.sbin/httpd/server_file.c#server_file_index

http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/httpd/server_file.c#rev1.52

cnst avatar May 14 '16 06:05 cnst