Apacheurl重写加号不能按预期工作

我想重写我的网站URL以下两种模式(注:有很多这样的url,我希望使用一个规则来重写它们都)

www.hetaoblog.com/hello www.hetaoblog.com/hello/ 

 **www.hetaoblog.com/myblogs/post/hello.jhtml** 

所有其他案例,如http://www.hetaoblog.com/不应该改变;

我试过了

 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] RewriteRule ^([^/]+)/$ /myblogs/post/$1.jhtml [L] RewriteRule ^(.*)$ /myblogs/post/$1.jhtml [L] </IfModule> 

 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] RewriteRule ^(.+)/$ /myblogs/post/$1.jhtml [L] RewriteRule ^(.*)$ /myblogs/post/$1.jhtml [L] </IfModule> 

 RewriteRule ^([^/]+)+/$ /myblogs/post/$1.jhtml [L] 

然而,他们为我想要的两个案件工作,但他们都将重写

 www.hetaoblog.com/ 

 www.hetaoblog.com/myblogs/post/.jhtml 

它看起来应该意味着至less有一个事件没有发生。

 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]*)/?$ /myblogs/post/$1.jhtml [L] 

您的/正在redirect,因为您的RewriteCond行不适用于第二个规则。

我仍然不确定你是如何确定它是如何被重写到/myblogs/post/.jhtml ,尽pipe这对你所遵循的规则来说是毫无意义的。

WordPress的可能仍然是干扰; 打开一个RewriteLog位置,并设置RewriteLogLevel 9以便我们可以确认Apache的行为正常。

最简单的是:

 RewriteRule /hello/? /hello.jhtml [L] 

这将完全匹配你指定的两个URI,没有其他的。

你有没有尝试过:

 RewriteRule ^/([A-Za-z0-9]+|[A-Za-z0-9]+/)$ /myblogs/post/$1.jhtml [L] 

您也可能需要指定rewritecond查询string。