【发布时间】:2017-02-04 18:20:07
【问题描述】:
假设我在 Apache 服务器上有一个具有这种文件夹结构的静态网站:
http://www.example.com
|
+-- /news/
| |
| +-- page1.html
| +-- page2.html
| +-- ...
|
+-- /otherstuff/
/news/文件夹内页面的url是:
http://www.example.com/news/page1.html
http://www.example.com/news/page2.html
现在,/news/ 文件夹中的文件数量正在增长,我想在 /news/ 中创建新的子文件夹并在这些新目录中拆分文件,但我还想隐藏 url 中的子文件夹名称。
新的文件夹结构将是:
http://www.example.com
|
+-- /news/
| |
| +-- /subfolder1/
| | |
| | +-- page1.html
| |
| +-- /subfolder2/
| | |
| | +-- page2.html
| +-- ...
|
+-- /otherstuff/
但页面的网址必须保持不变:
http://www.example.com/news/page1.html
http://www.example.com/news/page2.html
并且不是:
http://www.example.com/news/subfolder1/page1.html
http://www.example.com/news/subfolder2/page2.html
有没有办法在 .htaccess 中使用重写规则来实现这个结果?
我读过这个问题: How to use mod_Rewrite to check multiple folders for a static file
但接受的答案对我不起作用。
提前感谢您的任何建议。
【问题讨论】:
标签: apache .htaccess mod-rewrite url-rewriting