全球主机交流论坛

标题: 发现了一个目录列表,想请问一下如何去除url中的“?dir=“ [打印本页]

作者: HEAR    时间: 2020-6-27 18:19
标题: 发现了一个目录列表,想请问一下如何去除url中的“?dir=“
本帖最后由 HEAR 于 2020-6-27 21:39 编辑

这是目录列表的demo
https://demo.directorylister.com/

下载地址:https://www.directorylister.com/

点开目录后有
如:https://demo.directorylister.com/?dir=tests/Bootstrap
网上很多版本都是基于老版本修改去掉?dir=,没有这个版本好看。
想问下如何修改能够去掉?dir=


已解决,感谢yjsx86大佬的指导。
不知是否有人需要,修改版下载链接:https://pan.lanzous.com/iN0oMe3apbi


作者: coouk    时间: 2020-6-27 18:20
看不懂
作者: 鞠婧祎    时间: 2020-6-27 18:22
不知道伪静态是否可以
作者: 怪人    时间: 2020-6-27 18:28
提示: 作者被禁止或删除 内容自动屏蔽
作者: iks    时间: 2020-6-27 18:29
伪静态,同时需要程序支持
作者: HEAR    时间: 2020-6-27 18:36
鞠婧祎 发表于 2020-6-27 18:22
不知道伪静态是否可以

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

尝试了一下,看样子不行,还需要修改程序
作者: HEAR    时间: 2020-6-27 18:40
iks 发表于 2020-6-27 18:29
伪静态,同时需要程序支持

嗯,尝试了一下不行,看样子需要修改程序
作者: iiii.im    时间: 2020-6-27 18:57
伪静态的作用就是这个
作者: HEAR    时间: 2020-6-27 19:11
iiii.im 发表于 2020-6-27 18:57
伪静态的作用就是这个

啊 单纯伪静态没用 也可能是我写错了
location / {
rewrite /(.*)/$ /index.php?dir=$1 last;
}
作者: ABCHINA    时间: 2020-6-27 19:19
首先人家没有index.php,你给百度一个加上,误导论坛大佬,

location / {
rewrite ^/(.*)/$ /?dir=$1 break;
}
作者: HEAR    时间: 2020-6-27 19:29
ABCHINA 发表于 2020-6-27 19:19
首先人家没有index.php,你给百度一个加上,误导论坛大佬,

location / {

index.php加不加都能正常访问哦
例如https://demo.directorylister.com/index.php?dir=node_modules/axios
单纯伪静态估计解决不了。
伪静态之后例如
<link rel="icon" href="app/assets/images/favicon.light.png">就不能正常加载
修改为<link rel="icon" href="/app/assets/images/favicon.light.png">又出现各种其它问题。

谢谢你的耐心回答。
作者: yjsx86    时间: 2020-6-27 20:05
我的主要语言是 golang 和 python
php以前学过 看了下源码

单纯去除 ?dir= 可以在 app/src/ViewFunctions/FileUrl.php
  1.     public function __invoke(string $path = '/'): string
  2.     {
  3.         $path = $this->stripLeadingSlashes($path);

  4.         if (is_file($path)) {
  5.             return $this->escape($path);
  6.         }

  7.         if ($path === '') {
  8.             return '';
  9.         }

  10.         return sprintf('?dir=%s', $this->escape($path));
  11.     }
复制代码


上面的修改为:
  1.     public function __invoke(string $path = '/'): string
  2.     {
  3.         $path = $this->stripLeadingSlashes($path);

  4.         // if (is_file($path)) {
  5.         //     return $this->escape($path);
  6.         // }

  7.         if ($path === '') {
  8.             return '';
  9.         }

  10.         return $this->escape($path);
  11.     }
复制代码


由于本机没有趁手的php工具 不能debug
你会发现url是变了 但是程序出错
所以你还需要找到 源程序之前是怎么处理 ?dir=??? 的再进行修改
作者: ABCHINA    时间: 2020-6-27 20:10
HEAR 发表于 2020-6-27 19:29
index.php加不加都能正常访问哦
例如https://demo.directorylister.com/index.php?dir=node_modules/axio ...

这还不简单,静态资源应该在同一个url,用if把/app排除不就完了
作者: HEAR    时间: 2020-6-27 21:19
yjsx86 发表于 2020-6-27 20:05
我的主要语言是 golang 和 python
php以前学过 看了下源码

感谢大佬指点,照葫芦画瓢改了几个文件修改成功了!非常感谢
作者: HEAR    时间: 2020-6-27 21:39
ABCHINA 发表于 2020-6-27 20:10
这还不简单,静态资源应该在同一个url,用if把/app排除不就完了

解决了,感谢大佬
作者: 皇家    时间: 2020-6-27 22:53
去掉了不错。好人一生平安-----悠悠岁月,你说当年好困惑。。。。。




欢迎光临 全球主机交流论坛 (https://443502.xyz/) Powered by Discuz! X3.4