CodeIgniter在localhost中工作正常,但是当我传递给服务器时,只有索引页才有效

时间:2016-12-21 20:23:24

标签: php codeigniter

CodeIgniter 在localhost中工作正常,但当我将其传递给服务器时,只有index页面正常工作。

我尝试通过更改:

来更改config.php
  1. $config['uri_protocol'] = 'PATH_INFO';$config['uri_protocol'] = 'REQUEST_URI'
  2. $config['index_page'] = 'index.php';$config['index_page'] = 'index.php?';
  3. 但它仍然无效。

    config.php档案:

    $config['base_url'] = 'http://s661658794.onlinehome.fr/admin';
    $config['index_page'] = 'index.php';
    $config['uri_protocol'] = 'REQUEST_URI';
    

    .htaccess档案:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
    
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 year"
    </IfModule>
    ## EXPIRES CACHING ##
    
    
    <ifModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    </ifModule>
    <ifModule mod_headers.c>
        Header set Connection keep-alive
    </ifModule>
    
    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
    

    `

1 个答案:

答案 0 :(得分:0)

您是否在config.php中更改了base_url()

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

您应该添加新的.htaccess文件

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f

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

您需要更改database.php中的数据库设置并撤消在config.php中完成的所有上述更改