在特定網域上重定向“robots.txt”

在特定網域上重定向“robots.txt”

如果網域包含“.our-internal-devel-domain.de”,我想重定向“robots.txt”上的所有請求。它應該是伺服器範圍的,因為當我們開發一個網站並在我們的測試網域上發布它時,我不想讓它出現在谷歌上,所以我想提供一個拒絕所有的 robots.txt。

出於測試目的,即使在啟動專案後這些網域也確實存在,因此如果該網域不包含我們的 devel-domain,則應提供正常的 robots.txt。

例如一些偽代碼,但我沒有設法將它與 apache conf 中的 mod_rewrite 或 Alias 一起使用:

if current_domain.contains("our-internal-devel-domain.de") && querystring == "robots.txt" 
  deliver("/path/to/global/deny/robots.txt")

答案1

這可以很簡單

<VirtualHost *:80>
  ServerName our-internal-devel-domain.de>
  Alias /robots.txt /path/to/global/deny/robots.txt 
</VirtualHost>

相關內容