如何在htaccess重写规则中允许数字?

时间:2013-11-21 11:10:05

标签: .htaccess

我有像这样的htaccess设置:

RewriteRule ^([A-Za-z_]+)$ profile.php?name=$1 [NC,B,QSA]

它工作正常但是当参数中有数字时它不起作用。

是否可以允许句号和逗号?

我可以改变什么?

1 个答案:

答案 0 :(得分:1)

更改正则表达式:

RewriteRule ^([0-9A-Za-z_]+)$ profile.php?name=$1 [L,QSA]

或更好

RewriteRule ^(\w+)/?$ profile.php?name=$1 [QSA,L]

由于\w[0-9A-Za-z_]

相同

OP的评论:

  

is there a way to let it use periods and commas as well?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w,.]+)/?$ profile.php?name=$1 [QSA,L]
相关问题