我成功地更改了带有 SEO URL 的永久链接,但我遇到了大写问题。我用 <a href="<?php echo str_replace(' ', '-', $row['title']);?>
更改了 detail.php并创建了 .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
现在我想将大写 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']);?>
关于php - 如何使permlink大写为小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36232186/