Link to home
Start Free TrialLog in
Avatar of ChrisTERiS
ChrisTERiS

asked on

Remove illegal characters from SEO links

I'm using:
str_replace(" ", "-", $row['title']).'.html';

Open in new window

for building seo friendly urls, and it works fine. But there are some illegal characters eg % which are giving bad request.
Is there any function to remove all such illegal characters (I assume that there are other characters too).
I'm using PHP as server-side language.
Avatar of stergium
stergium
Flag of Greece image

Hello.
Why dont you try urlencode or htmlspecialchars or better yet a preg_replace?
Avatar of ChrisTERiS
ChrisTERiS

ASKER

Because I don't know which characters to add in the preg_replace.
ASKER CERTIFIED SOLUTION
Avatar of ChrisTERiS
ChrisTERiS

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Next time you have a question for EE, please give us some test data to work with.  You'll get faster and better results, I promise.  This article explains a little bit of the "why."
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7830-A-Quick-Tour-of-Test-Driven-Development.html
Because the other one was very generic.