【发布时间】:2016-12-18 05:26:01
【问题描述】:
我对正则表达式和 apache 网络服务器的 .htaccess 文件非常陌生。
我想重写一个 url,以便将第一个子文件夹转换为 GET 参数,并且以下所有子文件夹应保持原样...
几个例子:
http://www.example.com/thisisthevariable
应重写为
index.php?p=thisisthevariable
和
http://www.example.com/thisisthevariable/test.jpg
应重写为
test.jpg?p=thisisthevariable
和
http://www.example.com/thisisthevariable/subfolder/and/another/sub/folder/123.gif
应重写为
subfolder/and/another/sub/folder/123.gif?p=thisisthevariable
它应该适用于无限数量的子文件夹。所以除了第一个目录之外应该使用整个路径 - 这应该用作目标文件的获取参数。
希望,任何人都理解我的任务并可以帮助我:-)
谢谢!!
【问题讨论】:
标签: regex apache .htaccess redirect mod-rewrite