17

Running Apache on Ubuntu Precise, with PHP 5.5

Trying to access my var/www/ gives me a 500.

/var/log/apache2/error.log

shows:

/var/www/web/.htaccess: <IfModule> not allowed here

my .htaccess is:

DirectoryIndex app.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>

Into my apache.conf I added:

<Directory />
    AllowOverride ALL
</Directory>

And it worked after I restarted Apache.

1
  • You apparently have full control of your server. You can put the directives directly in the Apache httpd vhost configuration file. (It is a common misconception that redirects HAVE to live in .htaccess. You don't necessarily need .htaccess unless you have no access to the webserver config). httpd.apache.org/docs/2.4/howto/htaccess.html Dec 12, 2022 at 8:12

1 Answer 1

31

You need to configure your apache to enable configuration from the .htaccess file. So in the directory section be sure you have the option

Allowoverride ALL 

for more information more information about allowoverride.

In your setup if you use only mod_rewrite maybe you can set only FileInfo , I always set the Options parameter to SymLinksIfOwnerMatch to be able to perform redirection to other sites.

Allowoverride FileInfo 
Options SymLinksIfOwnerMatch

I hope it will help, if you already set this configuration please add information with your virtualhost configuration.

4
  • This is a fresh install of Apache. I have no <Directory /> section in apache2.conf. I've added my update above. Thanks
    – Kiksy
    Aug 6, 2013 at 13:18
  • I forgot to restart Apache. Thats working now .
    – Kiksy
    Aug 6, 2013 at 13:30
  • 1
    On my end I had a missing Directory directive. Once added, it worked properly. I suppose this is new in version 2.4 of Apache because it used to work with 2.2... Feb 24, 2014 at 9:09
  • 1
    Yes, the default value for Allowedoverride changed in Apache 2.3.9.
    – mlissner
    Oct 23, 2014 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .