0

If I have a URL that looks like this:

/Person/30/John Doe

When I send it in the browser, it of course gets translated to:

/Person/30/John%20Doe

In order to make the URL easier to read, I wanted to replace the spaces with dashes. Then before the values get read by the database, I swap out the dashes for spaces. I did this and it works great. Except when I have a value that contains a dash already, it breaks. So the name John Gloria-Gonzales becomes John Gloria Gonzales.

What's the best way to do this without screwing up the existing dashes?

ernest
  • 1,433
  • 2
  • 27
  • 41
  • 1
    Your problem with dashes in the name is precisely the reason that HTML entities like `%20` are used instead. Readability of URLs is not very high up on the scale of importance. – Robert Harvey Aug 05 '20 at 20:12
  • Dose this answer your question? https://stackoverflow.com/questions/25259/how-does-stack-overflow-generate-its-seo-friendly-urls/25537 – Mike Brind Aug 06 '20 at 10:53

0 Answers0