htaccess的mod_rewrite的有口音口音、htaccess、mod_rewrite

由网友(每天都可爱)分享简介:我有一个国际网站,该网站的一部分,用来创建一个新的人,在URL中的人的名字。我需要一个网址,让口音以及一些特殊字符,如A I have an international website, and a section of the website, used to create a new person, has th...

我有一个国际网站,该网站的一部分,用来创建一个新的人,在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]
阅读全文

相关推荐

最新文章