仅允许通过http访问robot.txt,其他访问https

时间:2015-01-22 14:10:51

标签: .htaccess http redirect https robots.txt

我想在https上重定向所有流量,只能通过http访问robot.txt。

是否可以为robot.txt文件创建例外?

我的.htaccess文件:

RewriteEngine On
RewriteCond %{SERVER_PORT}   !^443$
RewriteRule  (.*)  https://%{HTTP_HOST}/$1   [R=301]

1 个答案:

答案 0 :(得分:1)

确定你能做到:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule !^robots\.txt$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,NC,R=301,L]

确保这是根.htaccess中的第一条规则。

相关问题