.htaccess - HTTPS URL 中的 Codeigniter Index.php

标签 .htaccess codeigniter ssl https indexing

我在使用 CodeIgniter 和 htaccess 时遇到问题。

当我通过 http 或本地主机访问我的网站时,我可以访问 mysite.ext/controller/view ,例如 admin/login

但是当我之前使用 HTTPS 访问我的网站时,它发送了一个 404 错误,所以我必须写 mysite.ext/index.php/controller/vie w,它起作用了。

问题是我不想要 index.php,当我尝试在互联网上找到的解决方案时,它有时会删除 index.php,但我只能访问 /index/ Controller ,而不是管理员和其他人。

我在这里尝试了这个解决方案: codeigniter + not index.php with https

它删除了作为 Bootstrap 的 index.php,controller/view index/firstpage 工作,但不是其他 Controller 。

PS:HTTPS URL 不同于 HTTP URL。 HTTP URL 连接到服务器,但 HTTPS 由我的托管商提供(因此,https://ovh....blabla../mywebsite/)

我想了解为什么它不起作用并找到纠正方法。

最佳答案

在 https url 中没有为 codeIgniter 设置做任何特别的配置。首先,您从配置文件中删除 $config['base_url] 并在 $config['index'] 属性中放入 ''(blank) ..

您可以将 .htaccess 文件设置为...

<IfModule mod_rewrite.c>
 RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Rewrite all other URLs to index.php/URL
  RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
  </IfModule>
  <IfModule !mod_rewrite.c>
      ErrorDocument 404 index.php
  </IfModule>

以上代码是从 url 中删除 index.php。

关于.htaccess - HTTPS URL 中的 Codeigniter Index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19567947/

相关文章:

javascript - .htaccess 重定向不会发生

regex - Apache mod_rewrite .htaccess - 类似链接

.htaccess - 将整个站点重定向到子文件夹

php - 使用 codeigniter php 加载多个 View

eclipse - Maven 依赖项仅在命令行下载,不在 Eclipse 中下载

apache - URL 后面的双斜杠

php - .htaccess 1and1.com Codeigniter

javascript - CodeIgniter 和 JConfirmAction

php - 使用 Jquery Tree 插件配置 ul li 标签

ssl - 带有 TLS 和 JWT 的 MQTT 代理