views:

30

answers:

2

So I have an interesting problem here. I am using URL Routing to mask the URL but I want to take the spaces out.

For example:

/sanjuan/ but in the database it's San Juan. An error is thrown when I type it in because clearly theres a space in the DB. I don't want it conjoined in the DB though.

How can I accomplish this. I just need some ideas to look into.

+1  A: 

you could replace the space with - when rewriting the url, and change back the - back to space when reading it.

rob waminal
I wouldnt want someone to type san-juan though
Bry4n
@Bry4n, you can use `/san juan/` still but I think not all browsers reads space, and most browsers replace space with %20
rob waminal
Right they do but I dont want there to be any spaces in the url, but only in the database. I'm considering creating a different field for just the link =/
Bry4n
+1  A: 

What rob described is called slugging.

Have a look at this:

http://predicatet.blogspot.com/2009/04/improved-c-slug-generator-or-how-to.html

Ian P
+1 for defining it, I didn't know there's a term for that until now.. :)
rob waminal
I'm not quite sure what this does.
Bry4n