为什么用连字符和20%,谷歌的索引友好的URL混合使用吗? [英] Why is Google indexing Friendly URL mixed with hyphens and %20?

查看:189
本文介绍了为什么用连字符和20%,谷歌的索引友好的URL混合使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从无到有,事情的博客已经很大为止。我终于可以写我的第一篇/条,我一直在等待谷歌索引此特定的页面,以确保不会有任何与它的问题。那么,谷歌目前索引同一页面4次,我有(与用户的距离计算器的帮助下)一个mod_rewrite的在我的htaccess重写所有URL以连字符从一个特定的文件(article.php)的到来。

I developed a blog from scratch and things has gone great so far. I finally got around to writing my first post/article, and I've been waiting for Google to index this specific page to make sure there aren't any issue with it. Well, google is currently indexing the same page 4 times, I have (with the help of users from stackoverflow) a mod_rewrite on my htaccess to rewrite all urls to hyphens coming from a specific file (article.php).

我目前的文章页面站作为紧随其后。例: www.site.com/article.php?article_id=10&article_title=friendly URL转到这边

My currently article page stands as followed. example: www.site.com/article.php?article_id=10&article_title=friendly url goes over here

用的mod_rewrite我修改了网址下面的内容。

with mod_rewrite I have change the urls to the following.

www.site.com/article/id/friendly-url-goes-over-here

但谷歌似乎是索引同一页面的4倍,像这样......

but Google seems to be indexing the same page 4 times like so..

www.site.com/article/10/friendly-url-goes-over-here
www.site.com/article/10/friendly-url-goes%20over%20here
www.site.com/article/10/friendly-url%20goes%20over%20here
www.site.com/article/10/friendly%20-url%20goes%20over%20here

为什么索引4相同的页面呢?这似乎索引了多少次,每次连字符插入网页,因此,如果有10个连字符,我猜在同一页的谷歌将指数10 ..这是我所有的htaccess文件中。

Why is it indexing 4 of the same page? It seems to index the pages how many times each hyphen is inserted, so if there were 10 hyphens, I'm guessing Google would index 10 of the same page.. Here is all of my htaccess file.

RewriteEngine on

# add www before hostname
RewriteCond %{HTTP_HOST} ^oddify\.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 %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1/ [R=302,L,NE]

RewriteRule "^(article)/([^ ]*) +(.*)$" /$1/$2-$3 [L,R]

# 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]

我前几天写了这个问题,我确信脱指数从谷歌的页面,那么现在谷歌已经提前和重新索引他们以同样的方式。

下面是谷歌的网页显示4个索引页:<一href="https://www.google.com/search?q=site%3awww.oddify.co&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla%3aen-US%3aofficial&client=firefox-a"相对=nofollow>谷歌搜索页面

Here is the google pages showing the 4 index pages: google search page

推荐答案

尝试改变这种重定向到301:

Try changing this redirect to a 301:

RewriteRule "^(article)/([^ ]*) +(.*)$" /$1/$2-$3 [L,R=301]

301状态告诉谷歌(和浏览器等客户端)重定向是永久性的,旧的URL(带有空格)不应再被考虑。

The 301 status tells google (and browser and other clients) that the redirect is permanent and the old URL (the one with spaces) shouldn't be considered anymore.

这篇关于为什么用连字符和20%,谷歌的索引友好的URL混合使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆