在所有页面上强制https,但需要一个页面为http

时间:2015-07-16 16:37:21

标签: xml .htaccess http https

我们有一个网站,强制每个页面为https。然而,由于一些愚蠢的原因,Bing不支持站点地图在https下,因此我们需要将该页面设为http而不是强制它为https。我们如何写这个以便bing可以抓取站点地图?这是我们目前的.htaccess代码:

RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$0 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.example.com/$0 [R=301,L]

RewriteCond %{QUERY_STRING}  ^blog_search=
RewriteRule (.*)  https://www.example.com/pagenotfound?  [R=301,L]

RewriteCond %{QUERY_STRING}  ^blogkeysearch=
RewriteRule (.*)  https://www.example.com/pagenotfound?  [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php

我们需要让/sitemap.xml显示在http://www.example.com/sitemap.xml上,而不是强制使用https://www.example.com/sitemap.xml

1 个答案:

答案 0 :(得分:1)

您只是将其排除,因此不适用于该文件的https。

RewriteCond %{HTTPS} !^on
RewriteCond %{REQUEST_URI} !^/sitemap.xml [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
相关问题