301重定向,与重写规则相冲突重写、重定向、相冲突、规则

2023-09-02 10:09:56 作者:来往风尘客

我们今天做了一些维护,并动了我们的网站论坛,从/论坛到域的根文件夹。

We did some maintenance today, and moved our web forums from /forums into the root folder of the domain.

我们把一个重定向301 .htaccess文件:

We put in a redirect 301 in a .htaccess file:

Redirect 301 /forums/ http://www.ourforums.com/

不过,我们曾经有过包含重复/论坛文件夹一些链接。即www.ourforums.com/forums/forums/forum.1

However, we used to have some links that contained duplicate /forums folders. I.e. www.ourforums.com/forums/forums/forum.1

显然,从上面现在重定向导致/forum.1,这颂歌不存在的。我想旧的链接实际指向www.ourforums.com/boards/forum.1。我试图用这样的:

Obviously the redirect from above now leads to /forum.1, which odes not exist. I would like the old link to actually point to www.ourforums.com/boards/forum.1. I attempted to use something like:

RewriteRule ^/forums/forums http://www.ourforums.com/boards/ [NC,R=301,L]

不管是我的尝试,虽然,重定向似乎取代我把在同一文件中,任何的规则集不管我把他们重定向之前。

Regardless of what I tried though, the Redirect seems to supersede any RewriteRules I put in the same file, regardless of whether I place them before the Redirect.

有什么办法,我可以以某种方式确保重定向之前被处理的重写规则?

Is there any way I can somehow ensure the RewriteRule is handled before the Redirect?

推荐答案

手动添加重定向​​的语句,像这样似乎做的把戏对我来说:

Manually adding redirect statements like so seems to do the trick for me:

Redirect /forums/forums/forum.1 http://www.ourforums.com/boards/forum.1