[英]Default Controller of codeigniter shows blank page
here is my url structure- 这是我的网址结构-
demo directory contain my all codeigniter application files. 演示目录包含我所有的codeigniter应用程序文件。 I set my base path like this
我这样设置基本路径
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = "$root";
and also set $config['index_page'] = ''; 并设置$ config ['index_page'] =''; is blank.
是空白的。 My .htaccess file contain-
我的.htaccess文件包含-
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$1 [QSA,L]
Suppose i have a controller called Home and contain one method called index . 假设我有一个名为Home的控制器,并且包含一个称为index的方法。 I have set it as my default controller like this on my routes.php
我已经在我的routes.php中将其设置为我的默认控制器
$route['default_controller'] ='home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
// Catch all route
$route['home'] = 'home/index';
Now the problem is when i am using in my localhost(wamp) it works well. 现在的问题是,当我在localhost(wamp)中使用它时,它运行良好。 But when I uploaded it to my server and go to this url http://example.com/demo it shows blank page.
但是,当我将其上传到服务器并转到该URL http://example.com/demo时,它显示空白页。 It should show home controller.
它应该显示家庭控制器。 I have checked it that if problem present in Home controller.
我已经检查它,如果家庭控制器中存在问题。 Thats why I go to this url http://example.com/demo/home now its working fine but problem occurred when using the base url.
这就是为什么我现在转到此URL http://example.com/demo/home,它可以正常工作,但是在使用基本URL时出现问题的原因。
It's not needed to enter the route for your default controller. 不需要输入默认控制器的路由。 Just remove the line with
$route['home'] = 'home/index';
只需使用
$route['home'] = 'home/index';
删除该行$route['home'] = 'home/index';
; ; I think it's overriding your default configuration.
我认为这已覆盖您的默认配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.