Can I use non latin characters in my robots.txt and sitemap.xml?

use*_*110 5 sitemap robots.txt punycode domain-name

Can I use non latin characters in my robots.txt file and sitemap.xml like this?

robots.txt

User-agent: *
Disallow: /somefolder/

Sitemap: http://www.domainwithåäö.com/sitemap.xml
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

Or should I do like this?

robots.txt

User-agent: *
Disallow: /somefolder/

Sitemap: http://www.xn--domainwith-z5al6t.com/sitemap.xml
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

Mas*_*kin 0

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

\n\n

来自必应的示例:

\n\n
Your URL:\nhttp://www.domain.com/\xc3\x90\xc2\xbf\xc3\x90\xc2\xb0\xc3\x90\xc2\xbf\xc3\x90\xc2\xba\xc3\x90\xc2\xb0/ \n\nTo Disallow: /\xc3\x90\xc2\xbf\xc3\x90\xc2\xb0\xc3\x90\xc2\xbf\xc3\x90\xc2\xba\xc3\x90\xc2\xb0/\n\nWithout Percent encoding (Not Compatible):\nDisallow: /\xc3\x90\xc2\xbf\xc3\x90\xc2\xb0\xc3\x90\xc2\xbf\xc3\x90\xc2\xba\xc3\x90\xc2\xb0/\n\nWith Percent encoding (Compatile):\nDisallow: /%D0%BF%D0%B0%D0%BF%D0%BA%D0%B0/\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n

对于 XML 站点地图,可以使用非 ASCII 字符,但必须进行编码以匹配服务器的编码可读性。请参阅本指南,获取更详细的说明和示例。

\n

  • 问题是我是否可以在站点地图和 robots.txt 的域中使用非拉丁字符。但感谢您的尝试:) (2认同)