htaccess的mod_rewrite的有口音 [英] htaccess Mod_rewrite with accents

查看:112
本文介绍了htaccess的mod_rewrite的有口音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个国际网站,该网站的一部分,用来创建一个新的人,在URL中的人的名字。我需要一个网址,让口音以及一些特殊字符,如A

I have an international website, and a section of the website, used to create a new person, has the person's name in the URL. I need that URL to allow accents as well as some special characters like à

现在,我使用:

RewriteRule ^([áéíóúñÁÉÍÓÚÑäëïöüÄËÏÖÜçÇA-Za-z-]+)/?$ /newPerson.php?person=$1 [NC,QSA]

更新: 这工作,但不是很优雅的方式。我要求所有可能的A,A口音匹配所有字母(低和大写),A ...等,如果有这样的事情的一种更好的方式。

UPDATE: This works, but is not a very elegant approach. I am asking for a better way of matching all letters (lower and uppercase) with all possible accents à, á, ä... etc, if there is such a thing.

更新2: 有没有明显的方法来表示一个正则表达式的字符及其所有重音版本,所以我想我会坚持这个...

UPDATE 2: There is no apparent way to indicate in a regexp "a character and all its accented versions" so I think I'll stick with this...

推荐答案

您可以只允许任何东西,除了如 / 。正则表达式使用 [^] -notation这一点。你的情况,你可以使用:

You could just allow anything except e.g. / .. Regex uses the [^ ]-notation for this. In your case you could use:

RewriteRule ^([^/.]+)/?$ /newPerson.php?person=$1 [QSA]

这篇关于htaccess的mod_rewrite的有口音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆