【发布时间】:2020-08-31 12:21:53
【问题描述】:
我正在尝试通过 .htaccess 将 http://localhost/anay-bose 重定向到 http://localhost/anay-bose/1338.html(实际有效的 url)
这是我的规则:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9])$ /anaybose/$1 [R=301]
Redirect /anay-bose http://localhost/anay-bose/1338.html
问题是它正在重定向到诸如 http://localhost/anay-bose/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/ 之类的 URL 1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338.html/1338。 html
很多 1338.html 而我只需要一个 1338.html
寻找洞察力。
【问题讨论】:
-
你陷入了无限循环。 anay-bose 将以 /anay-bose 开头的所有内容重定向到 anay-bose/1338.html。但是 anay-bose/1338.html 再次匹配该规则并且 anay-bose 再次被重定向。尝试#### RewriteEngine on Redirect 301 anay-bose localhost/anay-bose/1338.html
-
“寻找见解” - 然后从阅读文档开始吧?对于
Redirect,它清楚地解释了该指令如何在 URL 路径上进行 prefix 匹配,并将任何多余的附加到目标 URL。
标签: javascript php .htaccess