重写规则为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
.
感谢所有帮助!