如何使permlink大写为小写

How to make permlink uppercase to lowercase

我成功更改了 SEO URL 的永久链接,但我遇到了大写问题。我将 detail.php 更改为 <a href="<?php echo str_replace(' ', '-', $row['title']);?> 并创建了 .htaccess `

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

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

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

现在我想将大写 url 更改为小写。

您可以在 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);

替换此代码 <?php echo seoUrl($row['title']);?>