簡體   English   中英

為什么用%20索引的友好URL?

[英]Friendly URLS indexed with %20 why?

Google正在為多個鏈接建立索引,而不是僅為其中一個添加多個連字符的301重定向建立索引。

我的網站url是通過以下方式設計的: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重定向,為什么Google仍會索引多個URL?

我會先搜索Google在哪里找到這個奇怪的網址。 我很確定沒有必要執行此重定向。

另外,請考慮每個頁面上的規范元標頭,以強制Google僅使用您選擇的一種URL表示方式。

例如:

<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/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM