Codeigniter网站上传到godaddy服务器后无法正常工作

时间:2018-01-18 10:41:49

标签: php .htaccess codeigniter codeigniter-3

我的网站在wamp中正常脱机工作,但在将其上传到服务器后,它会停止工作并发出错误404.

此外,我无法在wamp中将主页设置为离线。

我的route.php和config.php以及.htaccess在这里

route.php

$route['default_controller'] = 'front_controllers/home/home_controller/index';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

$route['index'] = "front_controllers/home/home_controller/index"; 
$route['tags'] = "front_controllers/tag_page/tag_page_controller/index"; 
$route['post/:num'] = "front_controllers/post/single/single_post_controller/index/$1"; 
$route['post/:num/:any'] = "front_controllers/post/single/single_post_controller/index/$1/$2"; 

的config.php

$config['base_url'] = 'http://localhost/codeIgniter/';
//$config['index_page'] = 'index.php';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

.htacess

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

我已经尝试过更改.htacess行了

 RewriteRule ^(.*)$ index.php/$1 [QSA,L]
to
 RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

如何在CI中设置主页? 任何方式让它在godaddy上工作

1 个答案:

答案 0 :(得分:0)

您的基本网址在配置文件localhost中仍为$config['base_url'] = 'http://localhost/codeIgniter/';。检查此行并替换为域名网址

$config['base_url'] = 'http://example.com/codeIgniter/';

但我推荐使用这样的基本网址

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 
相关问题