【问题标题】:codeigniter not work at live page not found error on servercodeigniter not work at live page not found 错误在服务器上
【发布时间】:2012-03-08 02:08:39
【问题描述】:

我的 codeigniter 在本地主机上运行良好,但在 live 上无法正常工作。我的 codeigniter 是最新版本。我也尝试过旧版本。它总是显示在重定向时找不到页面。

routes.php 设置为

$route['default_controller'] = "home";
$route['404_override'] = '';

我还在服务器上上传 htaccess。我在 linux 和 windows 上都试过了。

htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

【问题讨论】:

  • 你的本地和远程htaccess线路RewriteBase /怎么样?
  • 是的,请发布您的.htaccess
  • htaccess 在我的问题中更新。请检查这个
  • 您用来访问该站点的 URL 是什么以及该站点安装在哪个目录中? .htaccess 不是 Codeigniter 的要求,请尝试将其完全删除。另见:stackoverflow.com/a/3970634/398242
  • 您的 config.php URL 设置是什么?你确定你的应用程序是根域文件夹,而不是子目录吗?

标签: php .htaccess codeigniter


【解决方案1】:

你可以这样做:

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST']; //you can also leave blank this CI tend to find this by himself
$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO'; //if not working try one of these:
     'PATH_INFO'        Uses the PATH_INFO
    | 'QUERY_STRING'    Uses the QUERY_STRING
    | 'REQUEST_URI'     Uses the REQUEST_URI
    | 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO

试试这个.htaccess 我用于许多网站

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

如果还不工作,请使用phpinfo(); 并检查 mod_rewrite 是否为 enabled

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-30
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    • 2011-11-09
    • 2017-06-30
    相关资源
    最近更新 更多