douyan1944 2019-07-16 16:47
浏览 82

子文件夹中的Codeigniter管理应用程序显示404错误页面

i have the following problem..

I've created themain codeigniter website which is located in sub.domain.com and i've also created another codeigniter application (the admin) in sub.domain.com/admin..

*Note that i 'm not using HMVC model, in case someone mentions it...

The thing is that when i'm trying to access the /admin url i get a error 404 redirect problem.

Here are my main files and some extra things i shall mention:

.htaccess file:

Options -Indexes
Options +FollowSymLinks

# Indexes default
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /admin
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php/$1
</IfModule>

My routes.php file:

/**
* Users login - logout
*/
$route['login'] = 'users/users/login';
$route['logout'] = 'users/users/logout'; //Controller located in subfolder

$route['users'] = 'users/users';
$route['users/(:any)'] = 'users/users/$1';
/**
* Redirect any URI after default url
*/
$route['pages/(:any)'] = 'pages/$1';

/**
* Other routes
*/
$route['(:any)'] = 'pages';
$route['default_controller'] = 'pages';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

I also have this in my header.php file in which i redirect the user in login if not logged in etc.. etc..

if (!$this->ion_auth->logged_in() && $this->uri->segment(1) !== 'login') {              
    redirect('login');
} elseif( $this->ion_auth->logged_in() && !$this->ion_auth->is_admin($this->ion_auth->get_user_id()) ){
    redirect('logout');
}

The application/controllers structure is like:

Controllers
-Customers
--Customers.php
-Users
--Users.php
-Pages.php
etc..etc..

I've tried everything (.htaccess, RewriteBase /admin etc..) but still nothing works..

Any ideas? Thanks...

  • 写回答

1条回答 默认 最新

  • doucong1268 2019-07-16 19:08
    关注

    Try this:

    .htaccess in main application:

    AddDefaultCharset UTF-8
    Options -Indexes
    
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)admin(.*)$ /admin/index.php$1 [L]
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule (.*) index.php/$1
    </IfModule>
    

    .htaccess in /admin:

    AddDefaultCharset UTF-8
    Options -Indexes
    
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule (.*) /admin/index.php/$1
    </IfModule>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建