Subscribe To Our Newsletter

Sign Up Now To Get Free Coupon Codes, Event Coupon Codes Updates, Offers Updates. It's 100% Free!

We Hate Spam! Really, It's terrible and we never do it.

Slug Create Function in PHP. URL Rewriting According to SEO Rules

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:
 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;  
 }  
Share this article :

Post a Comment

Give your reviews about this blog. Leave your comments. what do you think about this post?

Meet Samee Ullah Feroz On Google Plus
Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.

---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards

 
Support : | Internet Marketing Specialist And Business Developer
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger