-
friendly urls
Hello,
I've managed to make friendly urls, but there's a slight problem with it heres an example what i get:
http://www.gamerspot.co.uk/news_area...20IV%20Delay!/
but as you can see, it displays the news title with "%20" which makes the url look messy. And what i want it to look like:
http://www.gamerspot.co.uk/news_area...GTA:IV-Delay!/
And my .htaccess code looks like this:
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule view_article/newsID/(.*)/title/(.*)/ view_article.html?newsID=$1&title=$2
RewriteRule view_article/newsID/(.*)/title/(.*) view_article.html?newsID=$1&title=$2
Is there a way that would get rid of "%20" and replace it with either "-" or "+" ?
Ben
-
Rather than using a full version of the title, it's easier for users to remember if you "slugify" it, removing unneccessary punctuation (which also tends to look ugly in URLs):
Code:
function slugify($str) {
return strtolower(preg_replace(array('/ /', '/\W/'), array('/-/', ''), $str));
}
Also, IMO, your URLs are too long. You can remove the variable names for a start, as well as having view_article be a sensible default action for articles, and end up with an URL that looks like /news_area/article/1/ps3-caused-gta-iv-delay.
-
where do i put that code ?