Htaccess文件重定向不再工作任何更多切换的https虚拟主机

时间:2016-10-19 16:25:04

标签: apache .htaccess redirect mod-rewrite bots

我最近使用虚拟主机将我的网站切换到https,机器人似乎现在没有重定向到快照页面,当我直接将网址重定向到https时该网站,但我的htaccess似乎没有注意重新直接蹲...

重定向到快照是在https之前正常工作..

RewriteCond %{HTTP_USER_AGENT} Googlebot
RewriteCond %{HTTP_HOST} https://upfrontbeats\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /snapshots/index.html [NC,L]

RewriteCond %{HTTP_USER_AGENT} facebookexternalhit/1.1|Twitterbot/1.0 [NC]
RewriteCond %{HTTP_HOST} https://upfrontbeats\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /snapshots/index.html [L,R=301]

这是下半部分仍然可以正常使用根网址

######################################THIS NEEDS TO GO ON TOP TO STOP RE DIRECT LOOP AS IT HITS SNAP SHOT DIRECTORY
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]  
################################

# RewriteCond %{HTTP_USER_AGENT} Googlebot
# RewriteCond %{HTTP_HOST} upfrontbeats\.com [NC]
# RewriteCond %{QUERY_STRING} _escaped_fragment_=(.*)$ 
# RewriteRule ^(.*)$ /snapshots/index.html [NC,L]

RewriteCond %{HTTP_USER_AGENT} facebookexternalhit/1.1|Twitterbot/1.0 [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_=(.*)$ 
RewriteRule ^(.*)$ /snapshots/$1 [L,R=301]

RewriteCond %{REQUEST_URI}  ^/$
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ /snapshots/%1? [NC,L]

RewriteRule ^(.*) /index.php [NC,L]

1 个答案:

答案 0 :(得分:1)

您只能使用HTTP_HOST变量匹配域名而非方案。

保留您的第一个重定向规则:

RewriteCond %{HTTP_USER_AGENT} Googlebot|facebookexternalhit|Twitterbot [NC]
RewriteCond %{HTTP_HOST} upfrontbeats\.com$ [NC]
RewriteRule ^/?$ /snapshots/index.html [L,R=301]