.htaccess - mod_rewrite : Redirect request to subdir with many subfolders of different structures + redirect to index. php

标签 .htaccess url mod-rewrite url-rewriting

我需要创建以下规则以放置在我的 .htaccess 中

  1. 对于每个请求,我想在子文件夹 subdir 中执行文件/路径。
  2. 如果该文件不存在,那么我想将此请求转发到 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/

相关文章:

.htaccess - 当我只浏览子域而不是完整的商店 url 时,Magento 浏览商店 View

php - 用php隔离部分url,然后在html元素中打印

php - htaccess 没有重写我的 GET 请求的 url

.htaccess - htaccess 替换url中的参数

url - 我应该担心 SEO 的 RSS 网址吗?

.htaccess - 如何在共享主机上部署 Symfony2?

apache - htaccess重写: Grab text after last slash as parameter

.htaccess - 文件名中的 %20,浏览器会看到空格。如何避免这种情况?

apache - 在 htaccess 重写规则中验证 utf-8

java - Android 图像未从图像 URL 显示到 ImageView