Mod rewrite and encoded URLs?

I have a rewrite rule set up to give pages such as “students/johnny_surname” rather than “/students.php?id=45”.

This is how it stands at the moment.


RewriteEngine on
RewriteBase     /dev/
RewriteRule ^students/([A-Za-z\_\'\-]+)/?$ students.php?student=$1 [QSA]

students.php takes the names supplied and gets the relevant details.

This all works fine, except for surnames with spaces in them.

If I navigate to

/students.php?student=min-kyung_kate%20nam

or

  • /students.php?student=min-kyung_kate nam*

Then everything works fine. The names are put through *urldecode() *and it works as expected.

But if I go to

students/*min-kyung_kate%20nam

*or

students/*min-kyung_kate nam

*Then the rewrite seems to fall over. I just get a 404.

Can anyone help?