Reputation: 10540
I noticed that various systems use various characters as the replacent for illegal ones in urls.
Is there a reason to use one or the other or should I just pick the one that looks best to me
The options I have seen so far include: - _ + and simply removing all illegal characters.
Upvotes: 0
Views: 742
Reputation: 32384
Just use - for space and get rid of the illegal chars (like this site is).
Also it's all lower-case.
Upvotes: 3
Reputation: 23759
Leaving out characters can make really strange strings. Really strange strings do not help for SEO.
The 'prettiest' solution is to transliterate your non-ascii characters to their ascii-equivalent. This can be done using Iconv (if you are on a unix platform)
You could also take a look at: How to handle diacritics (accents) when rewriting ‘pretty URLs’
But that is a PHP-specific question
Hope this helps
Upvotes: 1
Reputation: 54854
My preference is "-" and I use a very simple RegEx to replace everything that I don't want.
[^a-zA-Z0-9\-]*
This will replace any non alpha numeric characters and dash characters with a dash.
Upvotes: 1
Reputation: 158309
I would personally use _ to replace illegal characters and - for space. One other option would be to simply remove the illegal characters.
Upvotes: 1