.htaccess不会重写一个URL

.htaccess不会重写一个URL,.htaccess,.htaccess,我的.htaccess文件如下所示: RewriteRule ^One/?$ /xxyy/xxyy111.php [NC] RewriteRule ^Two/?$ /xxyy/xxyy222.php [NC] RewriteRule ^Three/?$ /xxyy/xxyy333.php [NC] https://mywebsite/One 1和3显示得很好,浏览器地址栏中的URL如下所示: RewriteRule ^One/?$ /xxyy/xxyy1

我的.htaccess文件如下所示:

RewriteRule   ^One/?$    /xxyy/xxyy111.php [NC]
RewriteRule   ^Two/?$    /xxyy/xxyy222.php [NC]
RewriteRule   ^Three/?$   /xxyy/xxyy333.php [NC]
https://mywebsite/One
1和3显示得很好,浏览器地址栏中的URL如下所示:

RewriteRule   ^One/?$    /xxyy/xxyy111.php [NC]
RewriteRule   ^Two/?$    /xxyy/xxyy222.php [NC]
RewriteRule   ^Three/?$   /xxyy/xxyy333.php [NC]
https://mywebsite/One

但是两个是

https://mywebsite/xxyy/xxyy222.php
我不知道去哪里寻找为什么会发生这种事


显然,这是一个信号(我猜)Apache更新其规则的问题。我对.htaccess进行了更改,将其指向一个不存在的文件,然后返回到原始文件,现在它可以正常工作。

我看到的一件事是,您需要在规则中使用
[L]
,以防止在找到匹配项时继续运行

RewriteRule ^One/?$ /xxyy/xxyy111.php [NC,L]
RewriteRule ^Two/?$ /xxyy/xxyy222.php [NC,L]
RewriteRule ^Three/?$ /xxyy/xxyy333.php [NC,L]

这可能会有所帮助,但无法解决问题。您需要尝试清除浏览器缓存。它通常会缓存规则,因此您可能会遇到这种情况。这条规则应该行得通。