Robots.txt restriction of category URLs

前端 未结 1 1318
谎友^
谎友^ 2021-01-28 08:48

I was unable to find information about my case. I want to restrict the following types of URLs to be indexed:

website.com/video-title/video-title/

(my website pr

1条回答
  •  清歌不尽
    2021-01-28 09:11

    This is not possible in the original robots.txt specification.

    But some parsers may support wildcards in Disallow anyway, for example, Google:

    Googlebot (but not all search engines) respects some pattern matching.

    So for Google’s bots, you could use the following line:

    Disallow: /*/video
    

    This should block any URLs whose paths starts with anything, and contains "video", for example:

    • /foo/video
    • /foo/videos
    • /foo/video.html
    • /foo/video/bar
    • /foo/bar/videos
    • /foo/bar/foo/bar/videos

    Other parsers not supporting this would interpret it literally, i.e., they would block the following URLs:

    • /*/video
    • /*/videos
    • /*/video/foo

    0 讨论(0)
提交回复
热议问题