问题
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