douweida2878 2015-02-01 16:14
浏览 19

更好的方法从$ _GET中删除/隐藏部件,但仍然可以捕获全部值

I'm working a flatfile blog style script project, the text file names are layed out like so:

05--im-a-title-and-may-c0ntain-lett3r5-and-numb3rs--14-12-2014

I use explode() -- to split into 3 parts for index listing

  • $id
  • $title
  • $date

link to single page being $title

The single page code at the moment is:

$search = $dir . "*" . clean($_GET['title']) . "*" . '.txt';

$files = glob($search);

$getfile  = $files[0];

echo file_get_contents($getfile);

As you see I am using globe() and it's wildcards to match the $_GET to file name to grab the file content and to remove/hide id and date parts from url which is working fine but once the files start piling up it will also start to get very server intensive having to search many files so wanting to fix this problem before it even starts so looking for a much better way to remove/hide parts from $_GET whist still finding the correct file.

Update: The purpose of this is to make single page url cleaner domain.com/i-am-a-title rather than domain.com/05--im-a-title--14-12-2014

Update 2: RewriteRule ^([a-zA-Z0-9_-]+)$ single.php?title=$1 [L]

  • 写回答

1条回答 默认 最新

  • 普通网友 2015-02-01 16:22
    关注

    Why are you searching file? Directly get the exact file.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大