# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
上面的.htaccess代码不会redirect到HTTPS。 为什么?
(IfModule被注释掉,目的是显示我没有错过重写模块)
更新
当尝试与http://htaccess.madewithlove.be我收到
RewriteCond %{HTTPS} =on This condition was not met RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301] This rule was not met because one of the conditions was not met RewriteCond %{REQUEST_FILENAME} !-f This variable is not supported: %{REQUEST_FILENAME} RewriteCond %{REQUEST_FILENAME} !-d This variable is not supported: %{REQUEST_FILENAME}
我的htaccess fu是最好的,所以我不能包裹我的头如何
RewriteEngine On
变
RewriteCond %{HTTPS} =o
得到评论
This condition was not met
或者那个
RewriteCond %{REQUEST_FILENAME} !-d
得到评论
This variable is not supported: %{REQUEST_FILENAME}
也许我很累。 也许我只是愚蠢的。
TIA
也许我很累。 也许我只是愚蠢的。
显然很累。
在编辑之前,我不记得你的确切configuration,但是根据你运行的testing,
RewriteCond %{HTTPS} =on This condition was not met RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301] This rule was not met because one of the conditions was not met RewriteCond %{REQUEST_FILENAME} !-f This variable is not supported: %{REQUEST_FILENAME} RewriteCond %{REQUEST_FILENAME} !-d
你似乎有以下的规则和条件:
RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
如果你rest一下后再看,很明显这不是你想要的。
RewriteCond %{HTTPS} =on
如果请求是httpS,则表示执行规则。 所以你要:
RewriteCond %{HTTPS} =off
在Htaccess testing人员的大力帮助下,stackexchange,@ETL和@Michael Hampton的另一个答案是:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
你们中的任何一个都可以复制我的答案,我会将其标记为(先到先得)并删除。 尊重那些应该的人。
而且要清理 – 我比累更笨。 自我的网站被closures后,也强调。
这导致我可以很好的了解一个警告 。 有一些奇怪的客户端caching? 这使得testing随机至less可以说。 目前redirect工作在Safari @ OSX和Chromium @ Win上,而不是在IE11 @ Win上。 为了我。 我想这个问题会在明天解决,或者当我打扰另一台机器时。
更新:我玩过更多。 在我的客户办公室http-> https在根层工作,但不是在IE中的每篇文章,而是挂起。 但是在Opera中呢。 第二天IE也工作了。 在家里我的IE做同样的空翻,但一天快一点。 两者都处于某种等待状态。
为什么我写了这么多关于失败的负载的胡言乱语是暗示下一个读者,快速编辑 – 保存 – 重新加载循环可能无法正常工作,并保持1个浏览器。