我需要创建以下规则以放置在我的 .htaccess 中
- 对于每个请求,我想在子文件夹 subdir 中执行文件/路径。
- 如果该文件不存在,那么我想将此请求转发到 index.php
假设 .htaccess iw 位于 http://domain/folder
当用户打开 url http://domain/folder/Subfolder/xxx.html 他应该从 http://domain/folder/subdir/Subfolder/xxx.html 收到文件
所以这些规则必须考虑 subdir 中有子文件夹的事实。 (子文件夹的不同结构:-) 并且仅当 subdir 下的路径不存在时,才应将请求转发到 index.php
请帮助:)
ps 这是我上一个问题的后续问题。这是完全不同的,包括在 subdir 中有子文件夹的事实。 -> mod_rewrite: How to search in local folder, subfolder and then redirect to index.php
最佳答案
为什么不简单地使用别名:
Alias /folder /subdir
然后在您的 404 页面中重定向到 index.php?它的优点是,404仍然被抓进了博客。
关于.htaccess - mod_rewrite : Redirect request to subdir with many subfolders of different structures + redirect to index. php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9330058/