多个应用程序 Codeigniter:从 URL 中删除 "index.php/controller"

Multiple apps Codeigniter: remove "index.php/controller" from URL

我是 CodeIgniter 的新手,正在尝试了解基础知识以及一些高级方法来设置基于 MVC 的应用程序。过了一会儿,我想我可能会尝试设置一个管理面板,并创建第二个文件夹作为管理应用程序。

这是我的文件夹结构:

www.domain.com
    --frontend
    --admin

每个文件夹中都有一个应用程序集,其中包含自己的 .htaccess 文件。下面是管理端的 .htaccess 文件。

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /admin/
RewriteCond  !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]    
</IfModule>

当前工作 url 是 www.domain.com/admin/index.php/admin/posts 我正在毫无意义地尝试将其更改为 www.domain.com/admin/posts。那么如何从 url 中删除 /index.php/admin。

$config['base_url'] 被相应地设置为每边 (admin/frontend) 并且默认的 index.php 也被设置为空,$config['index_page'] = '';

这是因为我有 2 个不同的应用程序还是只是配置错误导致的问题? 同一站点有多个应用程序的最佳做法是什么?

希望我没有重复任何 post 如果是这样请不要讨厌并尝试帮助我。非常感谢大家。

试试这个

在config.php

$config['base_url'] = '';
$config['index_page'] = '';

在 .htaccess 中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L] 
</IfModule>

编辑 01

<link href="<?php echo base_url(); ?>css/style.css" rel="stylesheet" />