首页 > 解决方案 > 使用 .htaccess 文件的 HTTP 到 HTTPS 重定向不起作用

问题描述

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

ErrorDocument 404 https://whatmovieshouldiwatchtoday.com/error404.php

php_flag display_errors 1

RewriteEngine On
RewriteRule ^/?movie/([0-9A-Za-z-:-]+)/?$ /movie.php?id=$1 [NC,L] 

RewriteEngine On
RewriteRule ^/?cast/([0-9A-Za-z-:-]+)/?$ /cast.php?cast=$1 [NC,L] 

RewriteEngine On
RewriteRule ^/?keyword/([0-9A-Za-z-:-]+)/?$ /keyword.php?keyword=$1 [NC,L] 

这是我的代码,现在这部分代码应该将 HTTP 重定向到 https,但它不起作用:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

当我尝试打开我的网站(即使使用 https)时,Google chrome 显示“Waiting For Whatmoviesshouldiwatchtoday.com”,几秒钟后,它显示

此页面不工作

whatmovieshouldiwatchtoday.com 将您重定向了太多次。

尝试清除您的 cookie。

ERR_TOO_MANY_REDIRECTS

标签: .htaccesshttphttpsserverhttp-status-code-301

解决方案


推荐阅读