简体   繁体   English

重定向 url 和 .htaccess 并重新编写错误的规则

[英]Redirect a url along with .htaccess and re-write rules gone wrong

I am trying to redirect http://localhost/anay-bose to http://localhost/anay-bose/1338.html (actual and valid url) via .htaccess我正在尝试通过 .htaccess 将 http://localhost/anay-bose 重定向到 http://localhost/anay-bose/1338.html(实际和有效的 url)

Here's my rule:这是我的规则:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9])$ /anaybose/$1 [R=301]
Redirect /anay-bose http://localhost/anay-bose/1338.html

Problem is it's redirecting to a url such as http://localhost/anay-bose/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/1338.html/1338.html/1338.html/1338.html/1338.html问题是它重定向到 url,例如 http://localhost/anay-bose/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/1338.html/1338.html/1338.html/1338.html/1338.html

Lots of 1338.html while I just need one 1338.html很多 1338.html 而我只需要一个 1338.html

Looking for an insight.寻找洞察力。

You need to enhance it a little via RedirectMatch Directive您需要通过RedirectMatch Directive稍微增强它

RedirectMatch ^/anay-bose$ http://localhost/anay-bose/1338.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM