gpt4 book ai didi

php - 如何在codeigniter中将http重定向到https

转载 作者:IT王子 更新时间:2023-10-29 00:21:26 25 4
gpt4 key购买 nike

第 1 点如果我输入:

www.myurl.com/somepage
http://www.myurl.com/somepage
http://myurl.com/somepage
https://myurl.com/somepage

让它重定向到

https://www.myurl.com/somepage

第 2 点

When I type in something like www.myurl.com it is redirecting to https://www.myurl.com/index.php.
Make it so the index.php is not displaying. It should just display https://www.myurl.com

来自评论 htaccess

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^myhost\.com$ [NC]
RewriteRule ^(.*)$ myhost.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$ myhost.com/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

最佳答案

我尝试了以上所有方法,但在我的情况下它们无法正常工作。我找到了以下解决方案,它适用于我的情况。希望对您也有帮助。

RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond $1 !^(index\.php|resources|robots\.txt|public)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

关于php - 如何在codeigniter中将http重定向到https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34586278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com