【发布时间】:2016-12-12 12:31:59
【问题描述】:
出于测试目的,我将所有代码和数据库记录从我们的实时服务器复制到本地服务器。
我编辑了以下文件:
/application/config/config.php(我也编辑了DB记录)
//$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'] = '**************';
但是当我打开网络浏览器时,我必须出现以下错误:
火狐:The page is not well redirected
铬:ERR_TOO_MANY_REDIRECTS
我已经尝试在 /application/config/config.php
中更改此设置$config['uri_protocol'] = 'AUTO';
使用所有其他值,但它们都不起作用。
我也尝试删除我的 .htaccess,但没有成功。
.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
实时服务器使用完全相同的代码运行而没有错误。 我真的不知道如何继续...... 我以前从未使用过 CodeIgniter,我可能需要启用特定的 PHP 扩展?
【问题讨论】:
-
这段代码看起来不错。可能是您在重定向时在控制器中犯了任何逻辑错误,并且可能会创建一个循环。一旦我遇到同样的问题,就我而言,当用户尝试在没有登录的情况下访问仪表板并且用户登录时,我正在重定向到登录页面,即使他/她尝试访问登录页面,我也试图重定向到仪表板。
-
@AniketSingh 有没有办法知道在 codeIgniter 中首先使用哪个控制器?
-
打开文件
application/config/routes.php并搜索行$route['default_controller'] = 'login';在我的情况下默认控制器是Login。每当您点击您的基本网址 ('localhost/test/');它将执行默认控制器的构造函数代码,然后执行同一控制器的索引函数。
标签: php codeigniter redirect