0

私の .htaccess ファイルには次のものがあります。

Options +FollowSymlinks
#+FollowSymLinks must be enabled for any rules to work, this is a security 
#requirement of the rewrite engine. Normally it's enabled in the root and we 
#shouldn't have to add it, but it doesn't hurt to do so.

RewriteEngine on
#Apache scans all incoming URL requests, checks for matches in our #.htaccess file 
#and rewrites those matching URLs to whatever we specify.

#allow blank referrers.
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?site.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?site.dev [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?dev.site.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


# otherwise forward it to index.php
RewriteRule . index.php

site.com は本番サイトです。

site.dev は localhost 開発環境です。

dev.site.com は、ライブ テストを行うサブドメインです。

これにより、サイトのインデックス作成が回避されることは承知しています。

Header set X-Robots-Tag "noindex, nofollow"

参照http://yoast.com/prevent-site-being-indexed/

ただし、私の質問はおそらくかなり単純です。

この行を dev.site.com にのみ適用して、インデックスが作成されないようにする方法はありますか?

4

1 に答える 1

1

この行を dev.site.com にのみ適用して、インデックスが作成されないようにする方法はありますか?

Headerはい、 vhost config に行を追加する必要がありますdev.site.comHeader sethtaccess ファイル内からディレクティブに関連付けられたホスト チェックを行う方法はありません。

もう 1 つの可能性は、ユーザー エージェントを介してボットをブロックする場合、削除してHeader setいくつかのルールを追加することです。

# request is for http://dev.site.com
RewriteCond %{HTTP_HOST} ^dev.site.com$ [NC]
# user-agent is a search engine bot
RewriteCond %{HTTP_USER_AGENT} (Googlebot|yahoo|msnbot) [NC]
# return forbidden
RewriteRule ^ - [L,F]

ユーザー エージェントのリストは完全ではないことに注意してください。ユーザー エージェントの膨大なリストを調べて、すべてのインデックス ロボット、または少なくともより人気のあるロボットを探すことができます。

于 2012-10-17T21:41:54.723 に答える