问题原文
原帖链接 · Noodles · CC BY-SA 3.0
Is there a way to swap out a robots.txt file in nginx based on hostname? I currently have www.domain.com and backup.domain.com pointing at the same nginx server, but I don't want Google indexing backup.domain.com.
已采纳解答
原帖链接 · ceejayoz · CC BY-SA 3.0
Two options:
- An
ifstatement based on$http_hostthat rewrites to one of two text files on the backend. - Have robots.txt be rewritten to a dynamic script (robots.php etc.) that responds accordingly.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
