我正在一个主要是自定义的站点上工作,HTTP没有被正确地重定向到HTTPS。
该站点加载良好,但HTTP版本没有正确地重定向,因此它显示为重复的内容。
我从几个不同的角度看过它,现在我感到一片空白。
重写index.php的HTTP请求,使其简单地命名为
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ https://www.*****.com [R=301,L]301重定向-如果网页缺少,则重定向到index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . index.php [L]修复规范化问题-如果缺少,则在HTTP请求上添加www
RewriteCond %{http_host} ^insynergystl.com [nc]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.insynergystl.com/$1 [r=301,nc] 总是使用https进行安全连接()
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.insynergystl.com/$1 [R=301,L]发布于 2018-09-03 19:57:58
尝试将https重定向到.htaccess中重定向列表的顶部,或者将其重定向到虚拟主机配置本身。
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]如果您将日志级别设置得更高一点,则可以调试重定向,只是不要忘记在测试的部分之后立即关闭它:
LogLevel alert rewrite:trace8
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
LogLevel alert rewrite:trace3rewrite.html#logging
在测试时,请确保只发出时态重定向,否则浏览器也会缓存重定向,即使代码不再使您重定向,也会重定向。
https://stackoverflow.com/questions/52143054
复制相似问题