友情网址索引为%20为什么?

时间:2014-02-27 17:46:14

标签: php .htaccess url mod-rewrite redirect

Google正在为多个链接编制索引,而不是仅仅添加一个是添加多个连字符的301重定向索引。

我的网站网址设计方式如下:url.com/id/title-goes-here/;如果谷歌要对以下内容进行索引,就会这样..

url.com/id/title-goes-here/ url.com/id/title%20-goes-here/ url.com/id/title%20goes%20here /

所以它有多少个连字符,当它只应该索引1连字符时,它会对网址数量进行索引。我已经包含301重定向但它仍然无法正常工作..

这是我的.htaccess代码..

RewriteEngine on

# add www before hostname
RewriteCond %{HTTP_HOST} ^site\.co$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]

#if on article page, get slugs and make into friendly url
RewriteCond %{THE_REQUEST} \s/article\.php\?article_uid=([^&]+)&article_title=([^&\ ]+)
RewriteRule ^ /article/%1/%2/? [L,R=302,NE]

#if page with .php is requested then remove the extension
RewriteCond %{REQUEST_URI} !/images/image_resizer.php
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1/ [R=302,L,NE]

#forces article title to redirect only once with hyphens
RewriteRule "^(article)/([^ ]*) +(.*)$" /$1/$2-$3 [L,R=301]

#Force a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s/+([^.]+?[^/.])[\s?] [NC]
RewriteRule ^ /%1/ [R=302,L]

#allow page direction to change the slugs into friendly seo URL
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule (?:^|/)article/([^/]+)/([^/]+)/?$ /webroot/article.php?article_uid=$1&article_title=$2 [L,QSA,NC]

#silently rewrite to webroot
RewriteCond %{REQUEST_URI} !/webroot/ [NC]
RewriteRule ^ /webroot%{REQUEST_URI} [L]

#.php ext hiding
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

为什么谷歌仍会为多个网址编制索引,即使连字符有301重定向?

1 个答案:

答案 0 :(得分:1)

我首先搜索Google发现这些奇怪网址的位置。我很确定没有必要进行重定向。

还要在每个页面上考虑规范元标题,以强制Google仅使用您选择的一种网址表示方式。

例如:

<link rel="canonical" href="http://url.com/id/title-goes-here/"/>

无论是哪个页面,都是 url.com/id/title-goes-here / url.com/id/%20title-goes-here / 搜索结果将是 url.com/id/title-goes-here /