我的代码点火器安装中的索引页面(又名homepage.php)无论如何都能正常工作。
问题在于使用子目录存储其他页面,目前其设置如下:
加载http://localhost/VAw_CI/
这样的主页工作正常(加载homepage.php),这是在routes.php中设置的:
$route['default_controller'] = "pages/homepage";
在config.php中,我已经设置:
$config['base_url'] = 'http://localhost/VAw_CI';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
我在上面指定了$config['index_page'] = '';
,因为我修改了位于htdocs
的.htaccess,如:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*homepage/$0 [PT,L]
但是,如果我尝试登录homepage.php,目前看起来像:
它将我发送到http://localhost/VAw_CI/pages/clientlogin
显示:
我有控制器设置如下:
这里给出了什么?当我访问http://localhost/VAw_CI
时,它正在有效地正确加载views->pages->homepage.php
视图,但似乎任何其他视图都不起作用我错过了某些页面其他的路径设置在我的情况下索引(homepage.php)?
答案 0 :(得分:4)
请在项目文件夹中创建.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>
您无需在配置文件中的base_url中定义:
$config['base_url'] = ''; // blank it.
答案 1 :(得分:0)
弄清楚我做错了什么:
我需要访问:http://localhost/VAw_CI/**index.php**/pages/aboutus
这很奇怪,因为我的默认CI页面设置为$ config ['index_page'] ='主页';
希望这可以帮助某人,有时候:)