Apache .htaccess即使启用了allowoverride也不工作

Apache .htaccess即使启用了allowoverride也不工作,apache,codeigniter,ubuntu,laravel,Apache,Codeigniter,Ubuntu,Laravel,我正在使用CodeIgniter,刚刚在Ubuntu 10.10云服务器上安装了一个LAMP堆栈 一切都很好,我启用了Apache userdir模块,因此我的主目录位于/home/myapp/public\u html,我通过进入servername/~myapp访问它 不幸的是,.htaccess重写似乎不起作用-它导致一个404错误,即无法找到文件/home/myapp/public\u html/index.php Mod_重写已启用 我知道您需要设置AllowOverride All指

我正在使用CodeIgniter,刚刚在Ubuntu 10.10云服务器上安装了一个LAMP堆栈

一切都很好,我启用了Apache userdir模块,因此我的主目录位于
/home/myapp/public\u html
,我通过进入
servername/~myapp
访问它

不幸的是,
.htaccess
重写似乎不起作用-它导致一个404错误,即无法找到文件/home/myapp/public\u html/index.php

Mod_重写已启用

我知道您需要设置
AllowOverride All
指令-我在
/etc/apache2/sites enabled/default
中设置了它-但重写似乎无法正常工作

我的
.htaccess
文件仅包含:

RewriteEngine on
RewriteCond $1 !^(index.php|img|stylesheets|js|icons|robots\.txt|user_guide)
RewriteRule ^(.*)$ index.php/$1 [L]
我的
/etc/apache2/sites available/default
如下所示:

<VirtualHost *:80>
ServerAdmin dan@danmatthews.me

DocumentRoot /var/www
<Directory />
      Options FollowSymLinks
      AllowOverride ALL
</Directory>
<Directory /var/www/>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride ALL
      Order allow,deny
      allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
      AllowOverride All
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root

        <Directory /home/*/public_html>
                AllowOverride All
                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                <Limit GET POST OPTIONS>
                        Order allow,deny
                        Allow from all
                </Limit>
                <LimitExcept GET POST OPTIONS>
                        Order deny,allow
                        Deny from all
                </LimitExcept>
        </Directory>
</IfModule>

我已经在谷歌上搜索和摆弄了好几个小时了,有人能帮我吗?

值得一提的是,我在Ubuntu服务器11.10和LAMP上遇到了一个非常类似的问题。我必须运行命令

sudo a2enmod rewrite

这对我很有帮助。也许这是你或其他人来这里的解决方案。

这对我也很有效。。。。在Ubuntu10.10中使用laravel也有同样的问题…我在Ubu12.04LTS上也遇到了这个问题,它成功了!!,很高兴我们有像stackoverflow这样的东西!