Nginx setup for subdirectory

Posted 3 years ago by chrisburton

Quick info:

I have my main site: site.com and I installed Laravel 5 in a subdirectory named 'laravel'.

I tried setting up a virtual host laravel.conf but I'm not able to get anything working. Any tutorial I try to follow, it's usually for setting up Laravel in a subdirectory but accessing it at the root domain level. I want to access Laravel via site.com/laravel and not site.com.

Laravel.conf file

server {
    listen 80;

    root /var/www/html/laravel/public;
    index index.php index.html index.htm;

    server_name site.com;

    access_log /var/log/nginx/localhost.laravel-access.log;
    error_log  /var/log/nginx/locahost.laravel-error.log error;


    location /laravel {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }


# ERROR
    error_page 404 /index.php; 


# HHVM
    include hhvm.conf; 


# DENY HTACCESS   
    location ~ /\.ht {
        deny all;
    }
}

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.