Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在这样的文件夹中有一个文件folder1/folder2/folder3/filename.htm。我也有另一个这样的文件folder1/folder2/folder3-filename.htm。当我浏览 urlmysite.com/folder1/folder2/folder3/filename.htm时,我希望folder3-filename.htm将被提供(显示)
folder1/folder2/folder3/filename.htm
folder1/folder2/folder3-filename.htm
mysite.com/folder1/folder2/folder3/filename.htm
folder3-filename.htm
我知道一些关于文件名重写规则的基础知识,但我还没有看到文件夹名和文件名的任何混合组合。
谁能帮我怎么做?
使用表达式[^/]+匹配直到但不包括下一个的所有字符/,然后.+匹配最后一个之后的所有字符/,以下将起作用:
[^/]+
/
.+
RewriteEngine On RewriteRule ^folder1/folder2/([^/]+)/(.+)$ folder1/folder2/$1-$2 [L]