开发者

.htaccess not working even though allowoverride is enabled

I'm using CodeIgniter and have just installed a LAMP stack on an Ubuntu 10.10 cloud server.

Ever开发者_StackOverflow社区ything is working great, and I have the Apache userdir module enabled so that my home directory sits at /home/myapp/public_html, and I access it by going to servername/~myapp.

Unfortuntely, .htaccess rewrite does not seem to be working - it causes a 404 saying the file /home/myapp/public_html/index.php could not be found - a 404 error.

Mod_rewrite is enabled.

I'm aware that you need to set the AllowOverride All directive - I have it set in /etc/apache2/sites-enabled/default - yet rewrite doesn't seem to be working properly.

My .htaccess file simply contains:

RewriteEngine on
RewriteCond $1 !^(index.php|img|stylesheets|js|icons|robots\.txt|user_guide)
RewriteRule ^(.*)$ index.php/$1 [L]

And my /etc/apache2/sites-available/default looks like:

<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

And finally, /etc/apache2/mods-enabled/userdir.conf looks like:

<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>

I've been googling and fiddling for hours, can anyone help please?


For what it's worth, I had a very similar problem with Ubuntu Server 11.10 and LAMP. I had to run the command

sudo a2enmod rewrite

which did the trick for me. Maybe it's the solution for you or some other people coming in here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜