Apache 重写引擎忽略了htaccess重定向

Apache 重写引擎忽略了htaccess重定向,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我有一个htaccess问题,我认为它可能非常简单(愚蠢?),以前没有人问过它。我从使用html页面转换为php,在大多数情况下,以下内容都起到了作用: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine on RewriteRule ^(.+)\.htm$ /htmlrewrite.php?page=$1 [R=301,NC,L] </IfModule> 在IfMofule上面。。。我想这

我有一个htaccess问题,我认为它可能非常简单(愚蠢?),以前没有人问过它。我从使用html页面转换为php,在大多数情况下,以下内容都起到了作用:

<IfModule mod_rewrite.c>
 Options +FollowSymlinks
 RewriteEngine on
 RewriteRule ^(.+)\.htm$ /htmlrewrite.php?page=$1 [R=301,NC,L]
</IfModule>
在IfMofule上面。。。我想这样做,但事实并非如此。“重定向301”将被忽略,除非我删除其余代码。有人能告诉我我做错了什么吗


TIA.

Apache首先处理mod_重写(rewrite*),然后处理mod_别名(重定向)

使用
RewriteCond
防止mod_rewrite处理/oldpage.htm

RewriteCond %{REQUEST_URI} !^/oldpage\.htm$
RewriteRule ^(.+).htm$ /htmlrewrite.php?page=$1 [R=301,NC,L]
或者使用
重写规则
而不是
重定向

RewriteRule ^oldpage\.htm$ http://example.com/newpage.php [L,R=301]
RewriteRule ^(.+).htm$ /htmlrewrite.php?page=$1 [R=301,NC,L]

您同时使用mod_rewrite和mod_alias,它们都应用于同一个URL。您应该坚持使用mod_rewrite或mod_alias

mod_rewrite:(删除
重定向
指令)


谢谢你,我选择了第二种方式,因为1号线已经有20条了。我试图将其标记为正确答案,但stackoverflow不断报告错误。
RewriteRule ^oldpage\.htm$ http://example.com/newpage.php [L,R=301]
RewriteRule ^(.+).htm$ /htmlrewrite.php?page=$1 [R=301,NC,L]
<IfModule mod_rewrite.c>
 Options +FollowSymlinks
 RewriteEngine on
 RewriteRule ^oldpage.htm$ http://example.com/newpage.php [R=301,L]
 RewriteRule ^(.+)\.htm$ /htmlrewrite.php?page=$1 [R=301,NC,L]
</IfModule>
Options +FollowSymlinks
Redirect 301 /oldpage.htm http://example.com/newpage.php
RedirectMatch 301 ^/(.+)\.htm$ /htmlrewrite.php?page=$1