一些关于 Directory Lister 逗比魔改版的再次修改,更符合自己的使用。

增设 Nginx 伪静态,去除链接中的 ?dir=

目录原链接:https://mirrors.abcd.com/?dir=softs 目录新链接:https://mirrors.abcd.com/softs/

修改方案

resources/DirectoryLister.php 第 218 行左右:

                $link = $this->_appURL . '?dir=' . rawurlencode($dirPath);
# 上方为原版,下方为修改后
                $link = $this->_appURL . '' . rawurlencode($dirPath) . '/';

resources/DirectoryLister.php 第 595 行左右:

                            $directoryPath = '?dir=' . rawurlencode($directoryPath);
# 上方为原版,下方为修改后
                            $directoryPath = '' . rawurlencode($directoryPath) . '/';

resources/DirectoryLister.php 第 618 行左右:

                            $urlPath = '?dir=' . $urlPath;
# 上方为原版,下方为修改后
                            $urlPath = '/' . $urlPath . '/';

resources/DirectoryLister.php 第 620 行左右:

                            $urlPath = $urlPath;
# 上方为原版,下方为修改后
                            $urlPath = $fileeePath;

resources/DirectoryLister.php 第 550 行后添加一行:

                $fileeePath = '/' . $directory . '/' . $file;

resources/themes/bootstrap/index.php,将第 25~32 行所有的 CSS、JS 引用链接前加 /

# 例如
        <link rel="shortcut icon" href="/resources/themes/bootstrap/img/folder.png" />

需要注意的是此处的修改会导致程序无法运行在子目录。

Nginx 伪静态:

location / {
 rewrite /(.*)/$ /index.php?dir=$1 last;
 }

参考