我可以在我的robots.txt和sitemap.xml文件中使用非拉丁字符吗?

5

我可以在我的robots.txt文件和sitemap.xml中使用非拉丁语字符吗?

robots.txt

User-agent: *
Disallow: /somefolder/

Sitemap: http://www.domainwithåäö.com/sitemap.xml

sitemap.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://www.domainwithåäö.com/</loc></url>
<url><loc>http://www.domainwithåäö.com/subpage1</loc></url>
<url><loc>http://www.domainwithåäö.com/subpage2</loc></url>
</urlset>

我应该这样做吗?

robots.txt

(机器人协议)

User-agent: *
Disallow: /somefolder/

Sitemap: http://www.xn--domainwith-z5al6t.com/sitemap.xml

sitemap.xml

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://www.xn--domainwith-z5al6t.com/</loc></url>
<url><loc>http://www.xn--domainwith-z5al6t.com/subpage1</loc></url>
<url><loc>http://www.xn--domainwith-z5al6t.com/subpage2</loc></url>
</urlset>
3个回答

1
https://support.google.com/webmasters/answer/183668中,谷歌写道:“确保您的URL遵循URI的RFC-3986标准,IRI的RFC-3987标准”,所以我想正确答案是您必须遵循这两个标准。 我最好的猜测是这并不重要,因为Google认为这两个URL是相同的。这也可能是标准中所述的内容,但我不擅长阅读这些内容,因此无法确认或否认。使用“xn--”格式是有效的。我还没有尝试使用Unicode字符来查看是否也有效。

0

由于您的示例包含US-ASCII表中没有的字符URI,因此您需要对它们进行百分号编码。

Bing的示例:

Your URL:
http://www.domain.com/папка/ 

To Disallow: /папка/

Without Percent encoding (Not Compatible):
Disallow: /папка/

With Percent encoding (Compatile):
Disallow: /%D0%BF%D0%B0%D0%BF%D0%BA%D0%B0/

这篇Bing博客文章可能会有所帮助。

对于XML网站地图,可以使用非ASCII字符,但必须进行编码以匹配您的服务器的可读编码。请参阅Google的这个指南,了解更详细的解释和示例。


2
问题是我是否可以在我的网站地图和机器人协议文件中使用非拉丁字符。但还是谢谢你的尝试 :) - user1087110
@user1087110 好观点!我刚刚编辑了我的答案,提供了有关sitemap.xml中外字符的更多信息。 - MGItkin

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接