我成功地用SEO URL更改了permlink,但我遇到了大写的问题。我用<a href="<?php echo str_replace(' ', '-', $row['title']);?>
和Created.htaccess `更改了detail.php
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']);?>