codeIgniter删除的index.php不工作 [英] CodeIgniter removing index.php not working
问题描述
我在使用Ubuntu 13以下设置为本地codeigniter网站。
I'm using Ubuntu 13 with the following setup for a local codeigniter site.
Apache/2.4.6 (Ubuntu)
5.5.3-1ubuntu2.2
'CI_VERSION', '2.1.2'
和网址不再工作没有的index.php
。他们曾经工作,但的Ubuntu的12.x
升级到 13.x
和几个apache的更新,在后过去一年中,本地主机
站点不再工作的权利。
And URLs are no longer working without index.php
. They used to work, but after upgrading from Ubuntu 12.x
to 13.x
and a few apache updates over the past year, the localhost
sites no longer work right.
如果我去本地主机/ index.php文件/ controllername /
它的工作原理,但如果我去到localhost / controllername /没有。
if I go to localhost/index.php/controllername/
it works but if I go to localhost/controllername/ it does not.
的mod_rewrite
已启用。
codeIgniter配置有:
CodeIgniter config has:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; // tried all available options here and
毫无效果
在 .conf文件
文件域我有这样的:
<Directory />
Options -Multiviews +FollowSymLinks
AllowOverride All
</Directory>
和这里的的.htaccess
文件注释行是那些我试过了,没有工作。
and here's the .htaccess
file commented lines are ones I tried that didn't work.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
# RewriteRule .* index.php/$0 [PT,L]
# RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
我GOOGLE和阅读一切我能找到,并试图一切我能找到其中的几个职位在这里对堆栈溢出,包括那些在可能已经有了你的答案的问题。不过似乎没有什么工作。但是就像我说的,这曾在过去,但只有经过多次更新操作系统和Apache没我第一次注意到它停止工作。
I’ve Googled and read everything I can find and tried everything I could find including several posts here on Stack Overflow, including the ones in the "Questions that may already have your answer." Still nothing seemed to work. But like I said, this worked in the past, but only after multiple updates to the OS and Apache did I first notice it stop working.
我会远离codeIgniter与未来的项目,但这些项目已经存在。感到困惑,可能是什么问题。
I’ll be moving away from CodeIgniter with future projects, but these projects already existed. Baffled as to what could be the issue.
解决方法:
原来这不是一个codeigniter问题都没有。这是一个Apache的问题,但不能与重写规则。 在我的apache2.conf我不得不改变了的/ var块/ WWW /
turns out it was not a codeigniter issue at all. It was an apache issue but not with the rewrite rules. in my apache2.conf I had to alter the block for /var/www/
要求所有授予似乎做的伎俩。
Require all granted seems to have done the trick.
DirectoryIndex的index.php文件的index.html 选择指标的FollowSymLinks 设置AllowOverride所有 要求所有批准
DirectoryIndex index.php index.html Options Indexes FollowSymLinks AllowOverride All Require all granted
只是良好的措施,我在这里所做的更改,以及: 有FollowSymLinks 设置AllowOverride所有 要求所有批准
just for good measure, I made the change here as well: Options FollowSymLinks AllowOverride All Require all granted
发现askubuntu <一href="http://askubuntu.com/questions/421233/enabling-htaccess-file-to-rewrite-path-not-working">http://askubuntu.com/questions/421233/enabling-htaccess-file-to-rewrite-path-not-working
found on askubuntu http://askubuntu.com/questions/421233/enabling-htaccess-file-to-rewrite-path-not-working
推荐答案
复制以下code到的.htaccess
在你的根文件夹
copy following code to .htaccess
in your root folder
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Options All -Indexes
这工作正常,我在codeIgniter删除的index.php。
This works fine for me to remove index.php in CodeIgniter.
这篇关于codeIgniter删除的index.php不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!