.htaccess 在某些网址上强制使用 https,否则强制使用 http

标签 .htaccess codeigniter ssl

我试图在网站的 3 个页面上强制使用 SSL,并强制其余页面使用 http

mydomain.com/register , mydomain.com/checkout 和 mydomain.com/thanks 都需要重定向到 https: 但任何其他页面应该只使用 http:

这可能吗?

目前我的 htaccess 中有一些 codeigniter 特定的东西

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

最佳答案

不是 .htaccess 解决方案,但这是我强制 https 连接的方式:

// Redirect to secure port
if ($_SERVER['SERVER_PORT'] != 443)
{
    $location = 'Location: https://www.blah.com';
    header($location);
}

希望这对您有所帮助。

关于.htaccess 在某些网址上强制使用 https,否则强制使用 http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11437065/

相关文章:

java - 如何在 Spring Boot 中从 Java 设置 TCPConnectionFactory 或 SSLServerSocketFactory

.htaccess - 多个域,一个 SSL,需要一个 htaccess 文件

.htaccess - 301 将所有丑陋的永久链接从旧站点重定向到新站点

php - 使用 codeigniter 电子邮件类发送电子邮件

php - 符号链接(symbolic link)破坏 CodeIgniter 上传库

node.js - 主机名/IP 与证书的替代名称不匹配

.htaccess - Zend Framework 2 中从 .htaccess 到 web.config 的 URL 重写

apache - .htaccess 将子域重定向到域

mysql - 我们如何在事件记录中进行多重连接 Codeigniter

angularjs - 如何在 https 中在 angularjs 上发帖