2014-03-02 45 views
1

如果在WordPress網站我的類別順序爲:通配符robots.txt中

-Parent 
--Child 
---Subchild 

我必須設置爲永久鏈接: %類別%/%postname%

我們用一個例子。 我使用帖子名稱「Sport game」創建帖子。 它的標籤是體育比賽。 它的完整網址是:domain.com/parent/child/subchild/sport-game 爲什麼我使用這種類型的固定鏈接恰好是在robots.txt中更容易地阻止某些內容。

現在這是我有問題的部分。 robots.txt中:

User-agent: Googlebot 
Disallow: /parent/* 
Disallow: /parent/*/* 
Disallow: /parent/*/*/* 

Disallow: /parent/*是否意味着這個規則,它的阻止domain.com/parent/child但不domain.com/parent/child/subchild而不是domain.com/parent/的?

Disallow: /parent/*/*/*是這樣的意思,它阻止domain.com/parent/child/subchild/,它只阻止subchild,而不是子級,不是父級,而不是子級下的帖子?

回答

3

請注意,Disallow中的*通配符不是原始robots.txt規範的一部分。有些解析器支持它,但由於沒有規範,它們可能都以不同的方式處理它。

由於您似乎對Googlebot感興趣,請參閱Google’s robots.txt documentation

在它變得清晰的例子那*意味着

任何字符串

「的任意字符串」 可以,當然,也包含/

因此,您的第一行Disallow: /parent/*應阻止路徑以/parent/開頭的每個網址,其中包括以斜槓分隔的路徑段。

注意,這將是相同Disallow: /parent/在原來的robots.txt規範,這也阻止任何URL其路徑與/parent/開始,例如:

  • http://example.com/parent/
  • http://example.com/parent/foo
  • http://example.com/parent/foo.html
  • http://example.com/parent/foo/bar
  • http://example.com/parent/foo/bar/
  • http://example.com/parent/foo/bar/foo.html