【问题标题】:htaccess exclude sitemap.xml and robots.txt from httpshtaccess 从 https 中排除 sitemap.xml 和 robots.txt
【发布时间】:2015-06-04 00:41:03
【问题描述】:

嘿,堆栈溢出者。

我被难住了,无法正确解决这个问题,我只想从 https 中排除根目录中的 robots.txt 和 sitemap.xml 中的两个文件。网站的其余部分通过 https,没问题。我得到了这个:

# Forcing HTTPS
# RewriteCond %{SERVER_PORT} !^443$  
# RewriteCond %{REQUEST_URI} !^sitemap.xml$
# RewriteCond %{REQUEST_URI} !^robots.txt$
# RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [L]

这显然会导致重定向循环等。所以...对 htaccess noobie 有什么帮助吗?

【问题讨论】:

    标签: .htaccess ssl robots.txt sitemap.xml


    【解决方案1】:

    试试这个规则:

    RewriteEngine On
    
    RewriteCond %{SERVER_PORT} !^443$  
    RewriteCond %{THE_REQUEST} !/(robots\.txt|sitemap\.xml)\s [NC]
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,NE,R=302]
    

    在新的浏览器中测试一下。

    【讨论】:

    • 传奇。似乎正在工作。那对我来说是5个小时的学习。非常感谢,是时候测试一下了!!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-28
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 2016-04-28
    • 1970-01-01
    相关资源
    最近更新 更多