【发布时间】:2015-01-14 10:12:22
【问题描述】:
有没有办法重写 robots.txt 的路径/文件名?
在我的 docroot 中,我放置了 robots.txt 和 robots_ssl.txt。现在我想“重定向”机器人,具体取决于他实际访问的站点。我在.htaccess 中制定了一条规则,内容如下:
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^robots\.txt$ robots_ssl.txt [L]
为了查看差异,我在两个文件的顶部添加了注释。当我调用https://example.com/robots.txt 时,它应该显示一个带有注释的 txt 文件:
https 的 robots.txt
否则,如果是http:
http 的 robots.txt
任何想法如何解决这个问题?我的 RewriteCond 错了吗?
【问题讨论】:
标签: .htaccess mod-rewrite robots.txt