问题描述
我有3个服务器,localhost apache服务器,测试远程服务器和生产活动服务器。
我有相同的安装codeigniter和网站设置对所有3个和在localhost和测试服务器路由没有'index.php'工作100%。然而,在生产服务器上,无论什么URL只说明首页(通过默认控制器)将显示,似乎所有路由规则被忽略,除了默认路由规则。
如果在URL中添加了index.php,那么它将按照预期的方式工作。
例如,如果生产站点上的URL是: .mysite.com / information',那么加载的内容构成默认控制器。
但是,当生产站点上的URL是:www.mysite.com/index.php/information时,加载的内容来自信息控制器。
这是我的htacess文件的内容:
这是我的路线配置文件: http://pastebin.com/7Ewc2bwN
我的$ config ['index_page']未设置。知道为什么它不工作,在所有服务器上的相同的设置在codeigniter本身和mod_rewrite IS在生产服务器上工作。
我不知道该怎么办
这是一个常见的问题,当人们移动一个codeigniter安装从一个环境到另一个环境。我不知道为什么会发生,可能是服务器操作系统或apache设置的差异,但解决方案往往是添加一个问号?
到RewriteRule的索引。 php在.htaccess文件中。
旧:
RewriteRule ^(。*)$ index。 php / $ 1 [L]
新:
RewriteRule ^(。*)$ index.php?/ $ 1 [L]
I have 3 servers, a localhost apache server, a testing remote server and the production live server.
I have the same installation of codeigniter and site set-up on all 3 of them and on the localhost and testing servers routing without 'index.php' works 100%. On the Production server however, no matter what the URL says only the homepage (via the default controller) will be shown, it seems all routing rules are being ignored except the default one.
If however index.php is added in the URL then it will work like it supposed to.
For instance if the URL on the production site is: 'www.mysite.com/information' then the content that loads is form the default controller.
But when the URL on the production site is: 'www.mysite.com/index.php/information' then the content that loads is from the 'information' controller.
This is the contents of my htacess file: http://pastebin.com/cDaZVJ8A
This is my routes config file: http://pastebin.com/7Ewc2bwN
My $config['index_page'] is set to nothing.
I really dont know why its not working, the same setup on all servers in term of codeigniter itself, and mod_rewrite IS working on the production server.
I don't know what to do, how can I find-out what's wrong?
This is quite a common problem that often occurs when people move a codeigniter install from one environment to another. I have no idea why it occurs, could be a difference in server OS or apache settings, but the solution is often to add a question mark ?
to the RewriteRule for the index.php in your .htaccess file.
Old:
RewriteRule ^(.*)$ index.php/$1 [L]
New:
RewriteRule ^(.*)$ index.php?/$1 [L]
这篇关于代码信号器,路由在生产服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!