nclsvh
nclsvh

Reputation: 2868

Exclude path/directory from 404 route in Laravel 5.2

I have an Laravel 5.2 application where I have a 404 route to catch all wrong urls and display an error. Now I simply want images in a specific directory to be open for all (non authenticated) users.


To make things a little bit more clear:

  1. These url's work ( see in routes file )
    http://website.com -> shows homepage
    http://website.com/about -> shows the about page
  2. I want to be able to surf to this url and see the image/file, but now this is redirected to my 404:
    http://website.com/signature/petergriffin.jpg

These are my routes at the moment.. Everything not defined under the 404 redirects to the 404 page.

Route::auth();  

// This is the 404 catch
Route::get('404', function(){
  return view('errors.404');
});  

Route::resource('/', 'HomeController');
Route::resource('/work', 'WorkController');
Route::resource('/about', 'AboutController');

...

Any help would be appreciated!

EDIT: the directory 'signature' has multiple images in them (at the moment 50) and the amount in increasing every day. So defining every single one will not be an option!

EDIT: this is the htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Upvotes: 2

Views: 1265

Answers (1)

Miguel Stevens
Miguel Stevens

Reputation: 9191

Try adding the following to your .htaccess, right before the RewriteRule line

RewriteCond %{REQUEST_URI} !^/signature

Upvotes: 2

Related Questions