This code removes all special characters from the given URL and make it SEO friendly.


PHP Code: 
    <?php           
    
function makeMyUrlFriendly($url){
        
$output preg_replace("/\s+/" "_" trim($url));
        
$output preg_replace("/\W+/" "" $output);
        
$output preg_replace("/_/" "-" $output);
        return 
strtolower($output);
    }
    
?>
Kevin Reviewed by Kevin on . Easiest way to make SEO friendly links using PHP This code removes all special characters from the given URL and make it SEO friendly. <?php function makeMyUrlFriendly($url){ $output = preg_replace("/\s+/" , "_" , trim($url)); $output = preg_replace("/\W+/" , "" , $output); $output = preg_replace("/_/" , "-" , $output); return strtolower($output); } Rating: 5