
ご検討いただくために、次の 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
# 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]
dev.site.com を Google 検索などで公開したくありません。
これを注文しました。待つべきでしょうか?それとも他に何かすべきことがあるのでしょうか?
答え1
.htaccess は、実際には、ウェブサイトが Google 検索インデックスに表示されないようにブロックする場所ではありません。 ロボットこの目的のために設計された方法の 1 つです。
これを配置します:
User-agent: *
Disallow: /
dev.site.com のルート ディレクトリにある「robots.txt」という名前のファイルで、表示されなくなるはずです。
あるいは、メタタグ表示したくないページには、次のように入力します。
<meta name="robots" content="noindex">
あるいは、のみGoogle にページをインデックスさせず、他のロボットの使用を許可するよう指示するには、次の操作を実行します。
<meta name="googlebot" content="noindex">
開発/本番環境のシナリオでこれを使用する場合の欠点は、これらのタグが本番環境のコードに表示されないようにするために何らかの対策を講じる必要があることです(するGoogle に本番サーバーをインデックスさせたい場合など)。