我试图在网站的 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/