php - codeigniter 无法在实时页面上工作,在服务器上找不到错误

标签 php .htaccess codeigniter

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

routes.php 设置为

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

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

访问权限

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

最佳答案

你可以这样做:

$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

关于php - codeigniter 无法在实时页面上工作,在服务器上找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9315316/

相关文章:

php - CodeIgniter 增删改查结构

php - 来自 PHP 的 PREPARE STMT 查询不起作用

javascript - 我可以将 PHP 与 Javascript 结合使用吗?

php - 我可以使用 Laravel 中的 Controller 创建数据库表吗?

php - URL 重写(内部/外部转发器).htaccess

php - Apache 重写 : file not found

php - 如何在 CodeIgniter base_url 中显示我的图像

php - Update Ignore 如果更新值将为负

php - strtotime() 使用 DD.MM.YY 输入返回当前日期 - 为什么?

php - 同时启用 PHP 解析器和 Include 语句