SEO friendly Slug is very important in Search Engine Optimization. It is used to rewrite your URL as your title.
as if you write title: "My Name Is Sami" And if it is a page. Then
Its URL will be :
www.QWC.me/?page=1 [1 Is Page ID]
If you use title in URL it can be like it
www.QWC.me/?page=my20%name20%is20%sami
But if you use slug function: URL will be SEO friendly like
www.QWC.me/?page=my-name-is-sami
There are many function: I am going to add 2 good functions for it. there is no any personal PHP built in function.
1:
2:
as if you write title: "My Name Is Sami" And if it is a page. Then
Its URL will be :
www.QWC.me/?page=1 [1 Is Page ID]
If you use title in URL it can be like it
www.QWC.me/?page=my20%name20%is20%sami
But if you use slug function: URL will be SEO friendly like
www.QWC.me/?page=my-name-is-sami
There are many function: I am going to add 2 good functions for it. there is no any personal PHP built in function.
1:
function slug($str, $replace=array(), $delimiter='-')
{
if( !empty($replace) )
{
$str = str_replace((array)$replace, ' ', $str);
}
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
$clean = form_validation($clean);
return $clean;
}
2:
function slug2($string){
$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
return $slug;
}
Post a Comment
Give your reviews about this blog. Leave your comments. What do you think about this post?
Comments Guidelines:
1) I love to read comments, but please avoid spam.
2) Like this blog, share your insights, and spread the word.
3) You can use basic HTML/xHTML tags.
4) All comments are DoFollow—please use the section professionally.
5) Kindly mention your name or brand below your comment.
6) Constructive suggestions for improvement are always welcome.
Thanks for visiting Samee Articles.
========================================
Best Regards,
Samee U. Feroz