codeigniter 如何使用.htaccess将https://重定向到https://www

r55awzrz  于 7个月前  发布在  其他
关注(0)|答案(1)|浏览(57)

我需要使用. htaccess重定向https://,http://到https://www。
这是我的基本网址https://www.mysite.co.bw/,我需要重定向https://mysite.co.bw/http://mysite.co.bw/到基本网址使用.htaccess
我在CodeIgniter 3中做了这个网站。
这就是我到目前为止所做的。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.co\.bw$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.mysite.co.bw/$1 [R=301,L]

# Your existing CodeIgniter rules
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

字符串
但是上面的代码对我不起作用。

qlfbtfca

qlfbtfca1#

你可以这样使用somthinge:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]

字符串

相关问题