Codeigniter 默认控制器不工作
我几乎已经使用 Codeigniter 完成了一个 Web 应用程序。在开发中,根目录是/readme/,我在.htaccess中使用以下代码来消除URL中的index.php:
RewriteEngine On
RewriteBase /readme
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我还将Readme_home设置为默认控制器,因此以下 URL 将直接指向默认控制器:
http://localhost/readme
对于生产,我使用与开发完全相同的配置,但以下 URL 不起作用并产生“禁止目录访问”错误:
http://www.mydomain/readme
相反,我必须使用
http://www.mydomain/readme/readme_home
默认控制器出现。是否有缺少的配置?如果有人可以在网上指出有关此问题的任何参考资料,那就足够了。如果我需要添加其他信息,请告诉我。谢谢先生,我真的很感激。
I have almost finished a web application using Codeigniter. In development, the root directory is /readme/ and I use the following code in .htaccess to eliminate index.php in the URL:
RewriteEngine On
RewriteBase /readme
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I also set Readme_home as the default controller, so the following URL will directly points to the default controller:
http://localhost/readme
For production, I use the exact same configuration as the one for development but the following URL does not work and produce 'Directory access is forbidden' error:
http://www.mydomain/readme
Instead, I have to use
http://www.mydomain/readme/readme_home
for the default controller to appear. Is there any missing configuration? If anyone can point out any reference on the web about this problem, that would be good enough. Let me know if I have to add additional information. Thank you sir, and I really appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
根据您的主机,您的
uri_protocol
可能无法正确检测。在 config/config.php 文件中,将uri_protocol
切换到列出的任何选项。我在 VPS 上运行我的应用程序时遇到了同样的问题。目前,PATH_INFO
有效。Try:
Depending on your host, your
uri_protocol
might not be detected properly. In your config/config.php file, switchuri_protocol
to any of the options listed. I've had the same issue when running my app on a VPS. Currently,PATH_INFO
works.