
고려할 만한 다음 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]
Google 검색 등을 통해 dev.site.com을 공개하고 싶지 않습니다.
저는 이것을 배치했습니다. 기다려야 할까요? 아니면 제가 해야 할 다른 일이 있나요?
답변1
.htaccess는 실제로 웹사이트가 Google 검색 색인에 표시되는 것을 차단하는 곳이 아닙니다. 로봇.txt이 목적을 위해 고안된 방법 중 하나입니다.
이것을 배치하면:
User-agent: *
Disallow: /
dev.site.com의 루트 디렉터리에 있는 "robots.txt"라는 파일에 이 파일이 표시되지 않도록 해야 합니다.
또는메타태그다음과 같이 표시하고 싶지 않은 페이지에:
<meta name="robots" content="noindex">
아니면 만약에오직귀하의 페이지를 색인화하지 않고 다른 로봇을 사용할 수 있도록 허용하려는 Google:
<meta name="googlebot" content="noindex">
개발/프로덕션 유형 시나리오에서 이에 대한 단점은 해당 태그가 프로덕션 코드에 나타나지 않도록 하기 위해 뭔가를 해야 한다는 것입니다(하다Google에서 프로덕션 서버의 색인을 생성하기를 원함)