重写规则不重定向

时间:2014-03-19 19:18:18

标签: .htaccess mod-rewrite

我试图将一个(htm)文件重定向到php文件。

我的重写规则如下所示:

RewriteRule ^market-intelligence/rfp/rfp-awards/proposals/winning-proposals_subscribers\.htm$ market-intelligence/rfp/rfp-awards/proposals/index.php [L,R=301]

但它没有重定向。我错过了什么?

由于

1 个答案:

答案 0 :(得分:1)

规则顺序在.htaccess中至关重要。通常,应该在内部重写规则之前保留所有外部重定向规则。可能发生的情况可能是内部重写规则可能会更改REQUEST_URI变量,这可能导致R=301规则失败或失败。

例如,如果你的上述规则出现在前控制器下面,那么这样的规则:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

RewriteRule ^foo$ /bar [L,R=301]

不会重定向/ foo到/ bar

相关问题