gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:08:00 36 4
gpt4 key购买 nike

我想将所有流量重定向到 https,只有 robot.txt 应该可以通过 http 访问。

是否可以为 robot.txt 文件创建异常(exception)?

我的 .htaccess 文件:

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

最佳答案

是的,你可以做到:

RewriteEngine On

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

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

关于.htaccess - 仅允许通过 http 访问 robot.txt,其他通过 https 访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28090833/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com