Caddy: Rewriting URL's for Laravel

Created on 14 Dec 2015  路  3Comments  路  Source: caddyserver/caddy

Given the following Caddyfile and a fresh Laravel setup with the following routes:

root ./public
fastcgi / /var/run/php5-fpm.sock php
errors error.log
<?php

Route::get('/', function () {
    return view('welcome');
});

Route::get('/foo', function () {
    return 'bar';
});

The index route works perfectly, but the /foo route can only be accessed at /index.php/foo.

Most helpful comment

This should work

rewrite {
    r .*
    ext /
    to /index.php?{query}
}

All 3 comments

The recommended NGINX configuration for Laravel is:

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

Don't know if that helps?

This should work

rewrite {
    r .*
    ext /
    to /index.php?{query}
}

Perfect :ok_hand:

You're my hero @abiosoft :)

Was this page helpful?
0 / 5 - 0 ratings