我有以下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]
我不希望通过谷歌search或类似的方式使dev.site.com公开。
我已经把这个地方。 我应该等一下吗? 还是有什么我应该做的?
.htaccess并不是阻止网站在Googlesearch索引中显示的地方。 robots.txt是为此目的而devise的方法之一。
放置这个:
User-agent: * Disallow: /
在dev.site.com的根目录中名为“robots.txt”的文件应该停止显示。
或者,您可以在不希望显示的网页中添加元标记 ,例如:
<meta name="robots" content="noindex">
或者,如果只是 Google,您不想索引您的网页,但允许其他机器人您可以使用:
<meta name="googlebot" content="noindex">
在开发/生产types的场景中,这个缺点是你必须做一些事情来确保这些标签不会出现在你的产品代码中(假设你希望Google为你的产品服务器build立索引)。