【发布时间】:2015-01-06 22:13:50
【问题描述】:
我有一个这样的文件夹/文件结构:
www.example.com/a/<optional subfolder>/file.png
我希望有一个 RewriteRule 将“a”作为第一个参数,之后的所有内容(file.png 或 subfolders/file.png)传递给一个名为 file.php 的文件,所以如果用户访问
www.example.com/a/file.png (this is not an actual file path, it's somewhere else)
应该改写成
www.example.com/file.php?user=a&file=file.png
和
www.example.com/a/random/subfolders/here/file.png
将被改写为
www.example.com/file.php?user=a&file=random/subfolders/here/file.png
我尝试了很多我在 Internet 上找到的 RewriteRules,其中一个甚至可以工作,但不适用于子文件夹。由于我对正则表达式一无所知,因此非常感谢您的帮助^^
【问题讨论】:
标签: regex .htaccess mod-rewrite parameters get