.htaccess - 在 .htaccess 中强制使用 HTTP

标签 .htaccess http https

我试图强制我的网站从 https 重定向到 http,大多数教程都做相反的事情(强制 http 到 https),到目前为止,我遇到的少数教程对我不起作用。

这就是我的 .htaccess 文件现在的样子

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

    # 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

最佳答案

使用它来强制使用 HTTP:

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

在测试之前请确保清除缓存。

关于.htaccess - 在 .htaccess 中强制使用 HTTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41873438/

相关文章:

angularjs - 向 Firebase 发出待处理请求的可能原因是什么?

java - Mule API 从 HTTP 迁移到 HTTPs

.htaccess - 无法一点一点地验证域

http - Angularjs - $http promise 错误处理

Apache 将子域重定向到文件夹,将文件夹作为子域处理

Python - 如果服务器在 PUT 完成之前回答,则 HTTP 模块无法解析响应

debugging - 当 Fiddler 可以解密时为什么还要使用 HTTPS

django - 在 Nginx 后面通过 HTTPS 访问 Django Admin

regex - mod_rewrite 规则 : if URL contains a certain string

node.js - 为什么 apache 重写 URL 两次?