重写规则为codeIgniter不工作 [英] Rewriterule for CodeIgniter not working

查看:156
本文介绍了重写规则为codeIgniter不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了一个干净的Apache2(加上PHP和放大器; MySQL的)服务器,并启用的mod_rewrite 在Apache的配置。
我加了的.htaccess 文件从作为codeIgniter维基描述的URL删除的index.php。

I have installed a clean Apache2 (plus PHP & MySQL) server and enabled the mod_rewrite in the apache config. I added the .htaccess file to remove the index.php from the url as described in the CodeIgniter wiki.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

我放置在网站的根文件。

I placed this file in the website's root.

当我尝试访问该网址 mydomain.local / index.php文件/欢迎然后我得到codeIgniter的默认页面。但是,当我试图通过 mydomain.local /欢迎访问同一页面然后我得到了404页。

When I try to access the url mydomain.local/index.php/welcome then I get the default page of CodeIgniter. But when I try to access the same page through mydomain.local/welcome then I get the 404 page.

我如何检查,如果整个重写规则是否有效?而为什么不工作?

How can I check if the whole rewrite rule is working? And why isn't it working?

推荐答案

我找到了解决办法。该htaccess文件是不允许通过Apache的配置来运行。因此,我不得不将的AllowOverride 标志对目录的AllowOverride ALL

I found the solution. The htaccess file wasn't allowed to run by the Apache config. So I had to set the AllowOverride flag on the directory to AllowOverride ALL.

感谢所有帮助!

这篇关于重写规则为codeIgniter不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆