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 ?
出于测试目的,我将所有代码和数据库记录从我们的实时服务器复制到本地服务器。 p >
我编辑了以下文件: p>
/application/config/config.php(我还编辑了数据库记录) strong> p>
的index.php 强> p>
/application/config/database.php strong> p>
但是当我打开网页浏览器时,我必须遵循以下错误: p>
Firefox: Chrome: 我已经尝试过c 在 /application/config/config.php strong> p>
使用所有其他值但没有一个值有效。 p>
我还试图删除 .htaccess strong>但没有成功。 p>
.htaccess strong> p>
实时服务器运行时没有 错误与完全相同的代码。
我真的不知道如何继续......
我之前从未使用过CodeIgniter,我可能需要启用特定的PHP扩展? p>
div>
// $ config ['base_url'] ='https://www.OurWebsite.eu/';
$config['base_url'] ='http:// 本地主机/测试/';
代码> PRE>
//定义 ('ENVIRONMENT','production');
define('ENVIRONMENT','development');
code> pre>
$ db ['default'] ['hostname'] ='localhost';
$ db ['default'] ['username'] = 'test_localhost';
$ db ['default'] ['password'] ='**************';
code> pre>
页面没有很好地重定向 code> p>
ERR_TOO_MANY_REDIRECTS code> p>
$ config ['uri_protocol'] ='AUTO';
code> pre>
&lt; IfModule mod_rewrite.c&gt;
RewriteEngine on
RewriteBase /
RewriteCond $ 1!^(主题)
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]
&lt; / IfModule&gt;
&lt; IfModule mod_deflate.c&gt; \ n&lt; filesMatch“\。(js | css | png)$”&gt;
SetOutputFilter DEFLATE
&lt; / filesMatch&gt;
&lt; / IfModule&gt;
AddOutputFilterByType DEFLATE text / ico text / html text / plain text / xml text / cs s application / javascript application / x-javascript application / x-httpd-php application / rss + xml application / atom_xml text / javascript
code> pre>
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 /
)
if you have used redirect in constructor than remove it i have the same problem but at last concluded that i have used redirect in constructor for login session
I had the same problem when I check project session array variables which variable use for check valid user that variable does not exist in this session array that's why it cause that's the problem (too-many-redirects). Check it's your session array or other variables. Maybe it's helpful for you.