# Mod rewrite and encoded URLs?

**URL:** <https://forum.kirupa.com/t/mod-rewrite-and-encoded-urls/229451>\
**Category:** programming\
**Created:** [June 17, 2007, 11:52am UTC](https://forum.kirupa.com/t/mod-rewrite-and-encoded-urls/229451 "2007-06-17T11:52:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duncanhall](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@duncanhall](https://forum.kirupa.com/u/duncanhall)\
**Post date:** [June 17, 2007, 11:52am UTC](https://forum.kirupa.com/t/mod-rewrite-and-encoded-urls/229451/1 "2007-06-17T11:52:06Z")

</div>

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.

```auto

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?
