Search code examples
apache.htaccesssymfonyubuntucapifony

Symlink to /project/current/web work but not to /project/current/web/app.php (Apache / Ubuntu / Symfony2)


Symlink to /var/www/myproject/current/web/ is working but is listing the web directory (not good).

Symlink to /var/www/myproject/current/web/app.php isn't working and give me this error : The requested URL / was not found on this server.

no logs in /var/log/apache2/error.log and this line in /var/log/apache2/access.log - 404 error

ip - - [17/Mar/2016:06:21:15 -0400] "GET / HTTP/1.1" 404 493 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36"

Here are the set up :

Symfony2 + Capisfony + Apache + Ubuntu 14.04

Here is my apache2.conf

<Directory />
        Options FollowSymLinks
        AllowOverride all
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Here is the .htaccess in /var/www/myproject/current/web

    DirectoryIndex app.php

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

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

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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>

And here is how I make the sym link

rm -rf /var/www/html
ln -s /var/www/myproject/current/web/app.php /var/www/html
service apache2 restart

==> 404

rm -rf /var/www/html
ln -s /var/www/myproject/web/app.php /var/www/html
service apache2 restart

=> You don't have permission to access / on this server.

[Thu Mar 17 06:44:53.385300 2016] [core:error] [pid 19767] [client 88.14.213.213:51484] AH00037: Symbolic link not allowed or link target not accessible: /var/www/html

Solution

  • The answer is :

    <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride all
            Require all granted
    </Directory>
    

    The AllowOverride None was blocking the .htaccess

    Thanks for helping.