.htaccesslaravellaravel-5envoyer.io

Envoyer.io, Laravel - Attempting to access contents of directory under /public


UPDATE

It seems like any PHP files placed under /storage/app/thirdpartydirectory are not being executed, instead the Laravel NotFoundHttpException is thrown. Simple text files, images, etc are accessible via http://example.com/thirdpartydirectory.

Original question

I am building a Laravel 5 site using Envoyer.io for code deployments. The way Envoyer works, new code is pushed to the site and placed under a /releases directory, then symlinked to /current from the top level (so /current always points to the latest /releases subdirectory).

The problem is that anything I put in my site's /public directory is included in the Envoyer deployments, thus replicated every single time I push new code. I am trying to use a third party app that must have its index.php and other files/directories directly exposed to the outside world. When the app is first loaded, an installation process begins and it installs additional config files into its various folders. When I deploy my next batch of code, /public is pushed again WITHOUT the installation and cache files generated by the third party app - thus causing a loop of having to run the installation process over and over again.

I reached out to Taylor Otwell regarding this and his suggestion was to place the app in /storage/app/thirdpartyapp and then make a symlink from each release's public directory before activating each new deployment -

cd {{release}}
ln -s /home/eyf/storage/app/thirdpartyapp public/thirdpartyapp

This creates a symlink without any issues but when I try to access the app (http://example.com/thirdpartyapp), I get stuck on the Laravel NotFoundHttpException page. The app has an index.php, if I go to http://example.com/thirdpartyapp/index.php, the Laravel site's index page is loaded instead - almost as if it's totally ignoring the symlink and /thirdpartyapp in the URL.

The app does ship with the following .htaccess, not sure if it makes any difference in all of this:

<IfModule mod_alias.c>
    # by default disallow access to the base git folder
    RedirectMatch /\.git(/|$) /404
</IfModule>

# cache images for a while
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
</IfModule>

# compress output if we can
<IfModule mod_deflate.c>
    # Set output filter for zipping content
    SetOutputFilter DEFLATE
    # Netscape 4.x and 4.06-4.08 have issues
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    # MSIE can be an issue, for now catch all MSIE
    BrowserMatch \bMSIE[56] !no-gzip !gzip-only-text/html
    # Exclude file types from compression
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|pdf|zip|tar|rar|gz|dmg|mp3|mp4|m4a|m4p|mov|mpe?g|qt|swf)$ no-gzip dont-vary
    # Make sure proxy servers deliver what they're given
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine ON

    # Set this if you have your installation in a subdirectory
    # RewriteBase /openvbx

    # By default always use SSL
    #RewriteCond %{HTTPS} !=on
    #RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*) index.php?vbxsite=$1 [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L,QSA]
    #RewriteRule ^(.*) index.php/$1 [L,QSA]

    ErrorDocument 404 /fallback/rewrite.php
</IfModule>

Solution

  • Apparently PHP code placed under /storage in a Laravel app isn't executed. I moved the third party app's directory to the parent folder and symlinked to that, now everything works.