【发布时间】:2014-03-17 13:33:55
【问题描述】:
我是这个网站的新手,希望能以正确的方式提出我的问题。
为了避免包含大量 ?id=11 等的 url 用于 SEO 目的,我构建了一个 url,允许我以这种方式重建这些 url:
http://www.example.com/blah-blah-blah-blah/
现在我更改了其中一些网址,因此我需要使用 .htaccess 将旧网址 301 重定向到新网址。问题是,当我重定向其中一个时,会添加 ?id=(+ number):
example: url to redirect /blah-blah-blah-blah/
example: url redirected to /blah-blah-blah-blah/?id=11
完成这项工作的函数是这样的:
function _prepare_url_text($string)
{
//remove all characters that aren't a-z, 0-9, dash, underscore or space
$NOT_acceptable_characters_regex = '#[^-a-zA-Z0-9_ ]#';
$string = preg_replace($NOT_acceptable_characters_regex, '', $string);
//remove all leaidng and trailing spaces
$string = trim($string);
//change all dashed, underscores and psaces to dashe
$string = preg_replace('#[-_ ]+#', '-', $string);
//return the modified string
return $string;
}
//buld a link that contains Type a Name
function make_name_url($IDName, $ID)
{
// prepare le type name and acc name for inlcusion in URL
$clean_ID_name = _prepare_url_text($AccName);
//build the keyword reach url
$url = SITE_DOMAIN . '/blah-blah-blah-blah-' . $clean_ID_name . '-A' . $ID . '/';
//return the url
return $url;
}
所有这一切的问题在于,Google 现在认为同一页面有两个副本。谁能帮我理解我能做些什么来解决这个问题?
【问题讨论】: