summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-11-05 06:03:38 +0000
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-11-05 06:03:38 +0000
commit141e9b1c8f9a53b3df94a01a925b88a40d847551 (patch)
tree8b5f3101a6cb56a848ca94a498d280c4ee375a71
parent7b54cb36f7e0b6230b20466976ada9b687b39dcb (diff)
add a trailing slash to directory URLs.
Besides saving a redirect, this is also a step towards making parabolaweb `manage.py syncisos` work.
-rw-r--r--index.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/index.php b/index.php
index 6a58209..44c56e4 100644
--- a/index.php
+++ b/index.php
@@ -169,7 +169,13 @@ if (!is_dir($root.'/'.$dirname)) {
echo "\t\t\t\t<tr class=\"".implode(' ', $classes)."\">";
echo "<td>";
- echo "<a href=\"".htmlentities($filename)."\">".htmlentities($filename)."</a>";
+ if (stat_is_dir($stat)) {
+ // stick a trailing slash on the URL; save a round-trip, since nginx will add it
+ // with a redirect
+ echo "<a href=\"".htmlentities($filename)."/\">".htmlentities($filename)."</a>";
+ } else {
+ echo "<a href=\"".htmlentities($filename)."\">".htmlentities($filename)."</a>";
+ }
if (stat_is_link($stat)) {
$target = readlink($root.'/'.$dirname.'/'.$filename);
echo " -&gt; <a href=\"".htmlentities($target)."\">".htmlentities($target)."</a>";