Ad

How To Make Permlink Uppercase To Lowercase

- 1 answer

I successfully changes permlink with SEO URL but i'm facing problem with uppercase. I changed detail.php with <a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="<?php echo str_replace(' ', '-', $row['title']);?> and Created .htaccess `

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.birthdaycakenames.com [NC]
RewriteRule ^(.*)$ http://birthdaycakenames.com/$1 [L,R=301]

AddDefaultCharset UTF-8
RewriteRule ^/(css|js|img)/(.*)?$ /$1/$2 [L,QSA,R=301]
RewriteRule ^([a-zA-Z0-9-/]+)/([a-zA-Z0-9-/]+)/?$ detail.php?title=$1&id=$2

RewriteRule ^([a-zA-Z0-9-/]+)/?$ detail.php?id=$1
Options -Indexes

now i want to change uppercase url to lowercase.

Ad

Answer

You can try this Function in PHP

$Title = 'For Example Title';
function seoUrl($string) {
    $string = strtolower($string);
    $string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
    $string = preg_replace("/[\s-]+/", " ", $string);
    $string = preg_replace("/[\s_]/", "-", $string);
return $string;
}
echo seoUrl($Title);

Replace This Code <?php echo seoUrl($row['title']);?>

Ad
source: stackoverflow.com
Ad