【问题标题】:Codeigniter 3 + multilingual + httpsCodeigniter 3 + 多语言 + https
【发布时间】:2017-02-25 16:54:25
【问题描述】:

我有一个英文和法文的网站 我的 htaccess 规则运行良好,但我想强制使用 https。

我在这里和那里尝试了几个例子,但我认为因为我使用的是双语系统,所以它不能按预期工作。

这是我的 htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# If your default controller is something other than
# "welcome" you should probably change this
# RewriteRule ^(app(/index)?|index(\.php)?)/?$ / [L,R=301]


RewriteRule ^(.*)/index/?$ $1 [L,R=301]

RewriteCond $1 !^(index\.php|images|assets|robots\.txt)

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.eot|\.ttf|\.svg|\.woff|\.woff2|\.gif|robots\.txt)$ [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]



</IfModule>

【问题讨论】:

  • 显示你为 https 尝试的代码!

标签: .htaccess codeigniter https


【解决方案1】:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#add this one as first rule
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# If your default controller is something other than
# "welcome" you should probably change this
# RewriteRule ^(app(/index)?|index(\.php)?)/?$ / [L,R=301]


RewriteRule ^(.*)/index/?$ $1 [L,R=301]

RewriteCond $1 !^(index\.php|images|assets|robots\.txt)

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.eot|\.ttf|\.svg|\.woff|\.woff2|\.gif|robots\.txt)$ [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]



</IfModule>

# Note: It’s also recommended to enable HTTP Strict Transport Security (HSTS)
# on your HTTPS website to help prevent man-in-the-middle attacks.
# See https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
<IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>

【讨论】:

  • 谢谢 Tpojka,我现在收到的消息是 Found 文档已移至此处。此外,在尝试使用 ErrorDocument 处理请求时遇到 302 Found 错误。
  • 您是否在服务器上启用了 SSL?
  • DNS 通过 cloudflare,所以通常是的
  • 它说“SSL:灵活”
  • 尝试不使用最后一个 if module 块。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-11-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多