大网数据广告活动
网站运营与故障问答

How to configure the robots.txt file with a multilingual site?

· 52CE 我爱测

I have a site with Drupal 8 and I activate English and French (Language from the URL path prefix). Here is what my url resembles : https://www.example.com/en/node/add https://www.example.com/fr/node/add And here is the current co…

问题原文

原帖链接 · ML19 · CC BY-SA 4.0

I have a site with Drupal 8 and I activate English and French (Language from the URL path prefix). Here is what my url resembles :

https://www.example.com/en/node/add

https://www.example.com/fr/node/add

And here is the current configuration of my robots.txt file :

# Paths (clean URLs)
Disallow: /admin/
Disallow: /comment/reply/
Disallow: /filter/tips
Disallow: /node/add/
Disallow: /search/
Disallow: /user/register/
Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/

How to configure the robots.txt file with a multilingual site ?

Do I have to add fr and praise each url or will it do it alone ?

已采纳解答

原帖链接 · unor · CC BY-SA 4.0

Disallow values need to start with the beginning of the URL path.

So Disallow: /node/add blocks https://www.example.com/node/add, but neither https://www.example.com/en/node/add nor https://www.example.com/fr/node/add.

If you want to block all variants of the node add page, you have to use:

Disallow: /node/add
Disallow: /en/node/add
Disallow: /fr/node/add

(Note that I omitted the trailing slash. If the node add page doesn’t have the trailing slash, the Disallow value must omit it, too, otherwise it wouldn’t match. If the node add page does have the trailing slash, omitting it in the Disallow value is no problem, it will still match.)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。