0

我有 www.amunzi.com/profile.php?username=anyusername 的重写规则

> RewriteRule ^([a-zA-Z0-9\._-]+[^.php])$ profile.php?username=$1  

> RewriteRule ^([a-zA-Z0-9\._-]+[^.php])/()$ profile.php?username=$1  

它工作正常,但问题是当用户名以字母“h”结尾时,会出现 404 错误。

4

1 回答 1

0

此正则表达式:将匹配 {alphanumeric characters or } 后跟除,或之外的任何字符^([a-zA-Z0-9\._-]+[^.php])$的任何非空字符串。._-.php

试试这个:

RewriteCond %{REQUEST_URI} !\.php$
RewriteRule ^([a-zA-Z0-9\._-]+)$ profile.php?username=$1

.php 重写条件应匹配所有不以(source)结尾的 URL ,并且重写规则中的正则表达式将匹配 {alphanumeric characters or ._-}的任何非空字符串。

于 2012-11-21T08:47:57.833 回答