具有重写规则的法语字符


French characters with rewrite rule

我的数据库中有类别名称,有些主题有法语字符,比如éèê。它一直按预期工作,直到今天我试图添加另一个字符à,然后我开始得到SERVER ERROR

这是我的.htaccess:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([A-Za-z0-9éèêà_-'s]+)-('d+)'.htm$   classified.php?id=$2 [L]

正如你所看到的,它在没有à的情况下运行良好。

如何将该内容添加到正则表达式中?

如果你使用所有类型的字符和重音字母,为什么不允许任何东西通过呢?

注意:使用此规则也将允许空格;

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)-('d+)'.htm$   classified.php?id=$2 [L]

稍后,如果你决定限制正则表达式,比如说你不想要这些字符#$%中的任何一个,那么你必须做出例外:

   Options +FollowSymlinks
  RewriteEngine on
  RewriteRule ^([^#$%]+)-('d+)'.htm$   classified.php?id=$2 [L]

URL中的扩展ASCII字符似乎是以UTF-8和URL编码的形式发送的。例如:

/éèêà-1.htm -> /%C3%A9%C3%A8%C3%AA%C3%A0-1.htm

上面的URL可以通过mod_rewrite进行匹配,如下所示:

RewriteEngine On
RewriteRule ^(?:'w|'xC3'xA9|'xC3'xA8|'xC3'xAA|'xC3'xA0)+-('d+)'.htm$ classified.php?id=$1 [L]