【发布时间】:2020-01-08 13:37:30
【问题描述】:
我遇到了这个问题:我从网上下载了一个登录/注册系统,并根据我的需要对其进行了调整,设置了所有目录和生根规则……一切正常,除了一件事。我在 kitematik 上运行灯,我的网站位于一个名为 appv2 的文件夹中。当我转到http://localhost:8080/appv2 时,会显示一个白页。但是如果我去http://localhost:8080/appv2/home 它会将我重定向到我的主页...现在,我怎样才能直接访问我的主页? 我尝试使用 .htaccess 和 routes.php 文件“玩”,但我无法弄清楚......这是我第一次遇到这个问题。我给你留了一个链接,这样你就可以下载项目的整个文件夹: https://file.io/qtCebE 下面我包括我的路由规则和 .htaccess 文件配置。
/////////////////////////routes.php///////////////
$route['register'] = 'user/register';
$route['login'] = 'user/login';
$route['logout'] = 'user/logout';
$route['home'] = 'user/home';
$route['appv2'] = 'user/home';
$route['default_controller'] = 'User';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['(:any)'] = 'user/$1';
//////////////////////////.htaccess////////////////
RewriteEngine on
RewriteBase /appv2/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /appv2/index.php/$1 [L,QSA]
【问题讨论】:
-
尝试 $route['(:any)'] = 'user/home';
-
@Vickel 已经尝试过了...不起作用...我也只是再次尝试确定...我认为问题可能出在 .htaccess 文件中,但没有得到它。 .
-
检查你是否有 $config['index_page'] = '';在你的 config.php
-
我有点想通了...但不是真的...在 codeigniter 设置中有些东西不正确...在我的主控制器“用户”中,索引类是空的...在那里我加载了页眉、主页和页脚,当我转到localhost:8080/appv2 时,它工作得很好......但这就像一个“解决方法”,因为在另一个项目中,我的主控制器的索引类是空的,我被重定向到我的主页...
-
@Vickel 我得到了这个:$config['index_page'] = 'index.php';
标签: php codeigniter frameworks