Mod rewrite apache2.2虚拟主机重写规则不匹配

Mod rewrite apache2.2虚拟主机重写规则不匹配,mod-rewrite,pattern-matching,apache2.2,Mod Rewrite,Pattern Matching,Apache2.2,我在虚拟主机中有一个非常简单的重写规则: RewriteRule ^/?([^.]+)\.([^(htm)]+)$ /$1.htm [L,QSA] RewriteRule ^/(someotherrule)$ /me [L] 说一个呼叫一个url:http://myurl.com/test.php 我希望规则匹配,url重写为http://myurl.com/test.htm 相反,我在我的日志中发现: applying pattern '^/?([^.]+)\\.([^(htm)]+)$'

我在虚拟主机中有一个非常简单的重写规则:

RewriteRule ^/?([^.]+)\.([^(htm)]+)$ /$1.htm [L,QSA]
RewriteRule ^/(someotherrule)$ /me [L]
说一个呼叫一个url:http://myurl.com/test.php

我希望规则匹配,url重写为http://myurl.com/test.htm

相反,我在我的日志中发现:

applying pattern '^/?([^.]+)\\.([^(htm)]+)$' to uri '/test.php'
applying pattern '^/(someotherrule)$' to uri '/test.php'
rewrite '/test.php' -> '/me'

显然,我的第一个重写规则模式有问题,但我看不出确切的原因。可能是因为我的大脑因睡眠不足而打结。因此,如果有人愿意花点时间指出我的错误,我将不胜感激。

您应该替换第一条规则,从而:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^[^.]+\.htm$ [NC]
RewriteRule ^/?([^.]+)\..*$ /$1.htm [L,QSA]

RewriteRule ^/(someotherrule)$ /me [L]
[^htm]中出现错误,这意味着文件扩展名不包含字符:、h、t、m,而不是预期的.htm