dou12754 2016-12-12 12:31
浏览 98
已采纳

localhost上的CodeIgniter:重定向太多

For testing purpose, I copied all the code and DB records from our live server to a local server.

I edited the following files :

/application/config/config.php (I also edited the DB record)

//$config['base_url']   = 'https://www.OurWebsite.eu/';
$config['base_url'] = 'http://localhost/test/';

index.php

//define('ENVIRONMENT', 'production');
define('ENVIRONMENT', 'development');

/application/config/database.php

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'test_localhost';
$db['default']['password'] = '**************';

But when I open a web browser I have to following error :

Firefox : The page is not well redirected

Chrome : ERR_TOO_MANY_REDIRECTS

I already tried to change this in /application/config/config.php

$config['uri_protocol'] = 'AUTO';

With all others values but none of them worked.

I also tried to delete my .htaccess without success.

.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteBase /

    RewriteCond $1 !^(themes)

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond $1 !^(index\.php|assets|static|img|css|js|map|favicon\.ico)
    RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
    RewriteRule ^sitemap\.xml$ ./index.php?/$1 [L,QSA]
    RewriteRule ^robots\.txt$ ./index.php?/$1 [L,QSA]

</IfModule>

<IfModule mod_deflate.c>
    <filesMatch "\.(js|css|png)$">
        SetOutputFilter DEFLATE
    </filesMatch>
</IfModule>

AddOutputFilterByType DEFLATE text/ico text/html text/plain text/xml text/css application/javascript application/x-javascript application/x-httpd-php application/rss+xml application/atom_xml text/javascript

The live server is running without errors with the exactly same code. I do not really know how to proceed... I never used CodeIgniter before, I may need a particular PHP extension enabled ?

  • 写回答

3条回答 默认 最新

  • dongqiancui9194 2019-03-20 12:45
    关注

    Finally I had to write this in my .htacces

    RewriteEngine on
    RewriteCond $1 !^(index\.php|public|\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1
    

    in the /application/config/config.php

    $config['base_url'] = 'http://www.my-site.local/'; //Don't forget the final '/'
    

    And in the database : http://www.my-site.local (without the trailing /)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动