.htaccess即使启用了allowoverride也无法正常工作

Dan*_*ews 12 apache ubuntu codeigniter laravel

我正在使用CodeIgniter并且刚刚在Ubuntu 10.10云服务器上安装了LAMP堆栈.

一切都很好,我启用了Apache userdir模块,这样我的主目录就可以了/home/myapp/public_html,我可以通过访问它来访问它servername/~myapp.

不幸的是,.htaccess重写似乎没有起作用 - 它导致the file /home/myapp/public_html/index.php无法找到404说- 404错误.

Mod_rewrite已启用.

我知道你需要设置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]
Run Code Online (Sandbox Code Playgroud)

/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
Run Code Online (Sandbox Code Playgroud)

最后,/etc/apache2/mods-enabled/userdir.conf看起来像:

<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>
Run Code Online (Sandbox Code Playgroud)

我一直在谷歌搜索和摆弄几个小时,有人可以帮忙吗?

jon*_*nas 23

对于它的价值,我遇到了与Ubuntu Server 11.10和LAMP非常相似的问题.我不得不运行命令

sudo a2enmod rewrite
Run Code Online (Sandbox Code Playgroud)

这对我有用.也许这是你或其他一些人来到这里的解决方案.