Skip to content

Commit f62189b

Browse files
committed
Update fallback instructions in README
1 parent bb67249 commit f62189b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,15 @@ Not even when you create your custom `errors.404` view.
267267
Therefor, the locale can't be set to match the requested URL automatically via middleware.
268268

269269
To enable localized `404` pages, you need to register a `fallback` route
270-
and make sure it has the `SetLocale` middleware and a name of `404`.
270+
and make sure it has the `SetLocale` middleware.
271271
This is basically a catch all route that will trigger for all non existing URL's.
272272

273273
```php
274274
Route::fallback(function () {
275275
return response()->view('errors.404', [], 404);
276-
})->name('404')->middleware(\CodeZero\LocalizedRoutes\Middleware\SetLocale::class);
276+
})->middleware(\CodeZero\LocalizedRoutes\Middleware\SetLocale::class);
277277
```
278278

279-
> Because you might use a `fallback` route for another purpose,
280-
this package will only consider it to be a `404` if you name the route `404`.
281-
282279
Another thing to keep in mind is that a `fallback` route returns a `200` status by default.
283280
So to make it a real `404` you need to return a `404` response yourself.
284281

@@ -290,6 +287,8 @@ Fallback routes will not be triggered when:
290287

291288
Because those routes are in fact registered, the `404` page will have the correct `App::getLocale()` set.
292289

290+
[Here is a good read about fallback routes](https://themsaid.com/laravel-55-better-404-response-20170921).
291+
293292
### 🚕 Generate Route URL's
294293

295294
You can get the URL of your named routes as usual, using the `route()` helper.

0 commit comments

Comments
 (0)