如果有人在 Code Igniter PHP 中使用 http 访问 URL,我想重定向到 https

问题描述 投票:0回答:1

如果有人在 Code Igniter PHP 中使用 http 访问 URL,我想重定向到 https。 我正在使用这个 htaccess 代码。帮我解决这个问题。

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

添加或更正 htaccess 代码。

php codeigniter https
1个回答
0
投票
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine On

# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Rest of htaccess
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
© www.soinside.com 2019 - 2024. All rights reserved.