【发布时间】:2018-03-10 12:53:31
【问题描述】:
我有一个网站,我将所有带有 .html 的页面重定向到“same name.php”。
RedirectMatch (.*)\.html$ $1.php
但是我有一个带有 index.html 的子文件夹并且没有使用 php,因此 Apache 请求 index.php 导致 404 错误。我通过制作一个虚拟 index.php 读取 html 文件并将 html 吐出到浏览器来使用一种解决方法。 我尝试了一种“简洁”的方法,在 index.html 的文件夹中使用了一个新的 .htaccess:
RedirectMatch (.*)\.html$ $1.html
但这会导致我已经害怕的循环重定向“重定向过多”。
有没有办法让 index.html 不在此特定文件夹中重定向的文件夹例外?
顺便说一句,我使用 Apache 2.4.x。它发生在 macOS、Ubuntu 和 Android (KSWEB) 上。
【问题讨论】:
标签: php html .htaccess redirect