开发者

Google News - URLs scheme and Primary Key

开发者 https://www.devze.com 2023-03-16 21:09 出处:网络
According to Google to allow your article/news to appear in Google News: Display a three-digit number. The URL

According to Google to allow your article/news to appear in Google News:

Display a three-digit number. The URL for each article must contain a unique number consisting of at least three digits. For example, we can't crawl an article with this URL: http://www.google.com/news/article23.html. We can, however, crawl an article with this URL: http://www.google.com/news/article234.html. Keep in mind that if the only number in the article consists of an isolated four-digit number that starts with 199 or 200, we won't be able to crawl it. Please note that this rule is waived with News sitemaps.

I have the following URL looking like this:

http://www.mydomain.com/news/91/this-is-news-title

This will not be accepted by google because News ID did not reach 119 or 200

So what can be done to change the prima开发者_运维问答ry key to start with 200? I already have 91 articles (From ID 1 to 91).

Is there a way to change NewsID 1 become 200, NewsID 2 become 201. Also I need to add 301 Redirect for old article ID's to new ID's ?

My site is developed in PHP and News data from MySQL database


For the SQL part, I guess you could do:

UPDATE news_table SET id=id+199 WHERE id<=91;

However, if Google has problems with isolated four-digit numbers that start with 199 or 200, you should probably begin at, say 2101. The relevant SQL update clause would then be:

UPDATE news_table SET id=id+2100 WHERE id<=91;

And for the redirecting part, assuming you are running Apache with mod_rewrite, something like:

RewriteEngine On
RewriteRule ^/news/([0-9]{1})/(.*)$ http://www.mydomain.com/news/210$1/$2 [R=301, L]
RewriteRule ^/news/([0-9]{2})/(.*)$ http://www.mydomain.com/news/21$1/$2 [R=301, L]

Not 100% sure about these. Obviously you want to test all this in a development environment.


Add leading zero's, so you'd have:

http://www.mydomain.com/news/091/this-is-news-title

Puting 091 instead of 91 will turn it into a 3-digit number, and crawlable.

Hope this helps. Cheers

0

精彩评论

暂无评论...
验证码 换一张
取 消