全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
12
返回列表 发新帖
楼主: HEAR

[翻译] 发现了一个目录列表,想请问一下如何去除url中的“?dir=“

[复制链接]
 楼主| 发表于 2020-6-27 19:29:39 | 显示全部楼层
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">又出现各种其它问题。

谢谢你的耐心回答。
发表于 2020-6-27 20:05:06 | 显示全部楼层
我的主要语言是 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=??? 的再进行修改
发表于 2020-6-27 20:10:20 | 显示全部楼层
HEAR 发表于 2020-6-27 19:29
index.php加不加都能正常访问哦
例如https://demo.directorylister.com/index.php?dir=node_modules/axio ...

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

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

解决了,感谢大佬
发表于 2020-6-27 22:53:28 | 显示全部楼层
去掉了不错。好人一生平安-----悠悠岁月,你说当年好困惑。。。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-3 21:04 , Processed in 0.061614 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表