7

对于搜索引擎优化的目的,我打算让一些文件从URL访问像http://example.ca/robots.txt但我面临一个奇怪的问题。这些文件可以通过firefox访问,但铬和谷歌机器人无法获得这些文件!路由到正在播放的静态文件!框架2.0

我的路线:

# Map static resources from the /public folder to the /assets URL path 
GET  /assets/*file    controllers.Assets.at(path="/public", file) 

# Robots and Humans files 
GET  /$file<(robots|humans).txt>    controllers.Assets.at(path="/public", file) 

GET  /$file<MJ12_576CD562EFAFA1742768BA479A39BFF9.txt>     controllers.Assets.at(path="/public", file) 
+0

你得到404错误?你确定没有被缓存的东西会导致这种情况吗? –

+1

看看另一个问题,其中铬使奇怪的东西:) http://stackoverflow.com/a/13103936/1066240 Thanx to @Schleichardt我解决了它通过添加favicon,检查与'onRequest'会发生什么。 – biesior

+0

我正在用空文件测试,看起来像chrome认为空文件是断开的链接... – Mooh

回答

19

我不知道它是否会有所作为,但尝试:

GET  /robots.txt    controllers.Assets.at(path="/public", file="robots.txt") 
GET  /humans.txt    controllers.Assets.at(path="/public", file="humans.txt") 

GET  /MJ12_576CD562EFAFA1742768BA479A39BFF9.txt     controllers.Assets.at(path="/public", file="MJ12_576CD562EFAFA1742768BA479A39BFF9.txt") 
+0

也可以将此用于'favicon.ico'。我将这个放在这里用于谷歌搜索。 – raisercostin