首页 > 解决方案 > 来自baseurl的codeigniter重定向

问题描述

我有一个 codeigniter 项目,我的 baseurl 为localhost/app

我的控制器是博客,所以当我访问时,localhost/app/blog我会获得有关视图的信息。虽然当我访问时,localhost/app什么都没有显示只有页眉和页脚。

所以我的问题是我如何重定向到我的主页,即localhost/app/blog当一些人进入时localhost/app

或者是否有任何其他解决方法可以解决这个问题,当仅调用基本 url 时它会重定向到控制器?

我的博客控制器(我使用 index 来查看它是否会自动重定向。

  public function index(){

  $data['title'] = 'Newest';


  $this->load->view('templates/header');
  $this->load->view('posts/index', $data);
  $this->load->view('templates/footer');

}

.htaccess

RewriteEngine On
RewriteBase /app
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

标签: phpcodeigniter

解决方案


推荐阅读