htaccess Mod_rewrite with accents

∥☆過路亽.° 提交于 2020-01-07 02:58:05

问题


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 à

Right now I'm using:

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

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.

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...


回答1:


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]


来源:https://stackoverflow.com/questions/10451601/htaccess-mod-rewrite-with-accents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!