2015-03-30 30 views
2
排除sitemap.xml和robots.txt

Hey Stack Overflowers。htaccess从https

我被难住了,不能得到这个正确的,我只想从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任何帮助吗?

回答

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] 

测试了这一点。

+1

图例。似乎工作。这5个小时为我学习。非常感谢,时间来测试一下! – 2015-03-30 20:44:07

+0

不客气,很高兴帮助。 – anubhava 2015-03-30 20:52:50