CodeIgniter 500内部服务器错误7

时间:2016-09-08 11:56:07

标签: php .htaccess codeigniter

这实际上是我第一次将CodeIgniter项目上传到Web服务器。我在转到其他页面时遇到问题,但默认控制器的index()工作正常。

我在互联网上搜索过相同的情况,但我找不到任何解决方案。

这是.htaccess文件

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /schoolportal
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php/$1 [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt|css)
  RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

当我尝试删除RewriteBase或将其更改为&#34; /&#34;时,我收到404 Not Found错误。

这是配置文件:

$config['base_url'] = 'http://sctportal.org/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

路线档案:

$route['default_controller'] = 'SchoolPortal';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

2 个答案:

答案 0 :(得分:0)

在config.php中做一些调整:

 // query the data
 var queryData = function(req, res) {

    // req.params contains the parameters from the call to this expressjs function
    // Lets assume you send a "startDate" parameter
    var startDate = req.params.startDate

    // authorize the client (see code above)
    authorize(function() {
    // do the actual call to the google api
    analytics.data.ga.get({
      'auth': jwtClient,
      'ids': VIEW_ID,
      'metrics': 'ga:uniquePageviews',
      'dimensions': 'ga:pagePath',
      'start-date': startDate,         // Then use the parameter here
      'end-date': 'yesterday',
      'sort': '-ga:uniquePageviews',
      'max-results': 10,
    }, function (err, response) {
      if (err) {
        console.log(err);
        return;
      }
      // send the data to the client (i.e. browser)
      res.send(response);
    }); 
  });
}

如果您使用Linux Server,还有一件事是必须进行这些更改。

1)您的班级名称应以大写字母开头,即$config['uri_protocol'] = "REQUEST_URI"; 应为cat

2)使用大写字母保存控制器类,Cat应为cat.php

答案 1 :(得分:0)

你能告诉你.htaccess到下面的

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

请您在配置文件中检查base_url

$root  = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url']    = "$root";

/*
|--------------------------------------------------------------------------
| 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'] = 'index.php';

中删除index.php
$config['index_page'] = 'index.php';

如果您不想在您的网址

中使用index.php