Zoli
Zoli

Reputation: 1081

Laravel application: serve static files from outer public directory

I have a Laravel application in a directory:

/var/www/html/example/

The public folder of the site is:

/var/www/html/example/public/

I have a folder outer public folder with images, css/js and other files:

/var/www/html/example/application/themes/

I want to serve these files from this folder as follows:

http://www.example.com/themes/

Here is the current .htaccess file:

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

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]</IfModule>

Can you help me with the completition of the htaccess file, to serve the files from within the outer public folder. I made a few tests, but I get 500 or 400 errors.

Upvotes: 2

Views: 1855

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163768

I don't know why do you want to do that, seems to me like it's not a good idea. But if you really need this, the simpliest way to do that is to use symbolic links.

ln -s /var/www/html/example/application/themes/ /var/www/html/example/public/themes/

Upvotes: 1

Related Questions