Repository navigation
Route Redirect
Dory Azar edited this page Nov 15, 2026
·
1 revision
Route::redirect($from, $to, $status = 302, $options = []) answers a GET by sending the visitor elsewhere, without
a closure or a controller: an address that moved, a short address, the home page of a section. Since 2.19.0;
keepQuery since 2.20.0.
Route::redirect('/catalog', '/books'); // 302
Route::redirect('/old/books/{id}', '/books/{id}', 301); // moved for good"Redirect /catalog to /books, and the old /old/books/{id} addresses to /books/{id} for good."
-
In
application/config/routing/web.php, beforeRoute::run();:Route::redirect('/catalog', '/books');
-
Run
curl -s -i http://localhost:8080/catalog: it answers302 FoundwithLocation: http://localhost:8080/books.
-
{name}in the target takes the route variable of the same name (url-encoded); the query string never fills it (/old/books/2?x=1goes to/books/2). - The target is a path of the site or a full
https://address. - The status is
301,302(default),303,307or308; anything else, or an empty target, stops with an error whenweb.phpruns. -
['keepQuery' => true](2.20.0) takes the query string along:/old?page=2goes to/new?page=2. A#fragmentof the target stays last.
Route::redirect('/old', '/new', 301, ['keepQuery' => true]);-
A redirect that depends on who asks, or on the data: that is a
Route::actionwhose capability returnsWeb::redirect(...). -
redirect()in a closure withoutreturn:redirect()only sends aLocationheader; code after it still runs.Route::redirecthas no such problem. -
Expecting the query string to fill
{name}: only the route variables of$fromdo.
- Routing: how a request finds its route
- Everything else:
Route::action - Declarative routes
Caligrafy: Describe it. Approve it. Ship it. Your idea turned into a complete app: every feature built once, for web pages, Vue apps, a REST API and AI agents, and online.
Why Caligrafy: the benefits, the measurements, and what it is not yet
-
Quickstart with Claude: describe it, approve it, ship it
or the Quickstart: the same three steps by hand, in 5 minutes
- How Caligrafy works: the ideas in 5 minutes
- Your first capability: build a feature, page included
-
Capabilities in depth
-
#[Capability]: every option - Scheduled jobs: capabilities on a timer
- Notifications: web push and email
- Background jobs: capabilities run later
- Migrations: database changes, in order
- The cache
-
Testing your app
- Dependency injection
- Validation rules
-
Web pages
- Views and page components
- Design styles: another look, one setting
- Declarative routes: every request, in one line
-
Route::page·Route::form·Route::auth·Route::webhook·Route::download·Route::redirect·Route::action·Route::snap· capability routes - How to export a list as CSV
- Controllers: moving one to a declared route · how to, step by step
- Forms and helpers
-
Vue apps
-
Mobile and tablet
-
REST API
-
AI agents
-
Snap Cards and the assistant
- Payments: Stripe and crypto
- Face detection and face login
- OpenAI: chat and images · Assistants
- Open models: Llama, Mistral...
- Chatbots with Watson
- Machine learning in the browser
- Metadata and social cards · search and analytics
-
Putting it online: the production image, the database at every start
-
API reference: every class and method
-
Routing ·
Route·AuthRoutes· pages ·Controller· capabilities -
Data ·
Model·Query· sign-in · jobs ·Notify· payments · AI -
Interfaces · Snap ·
Snap\Cards·Snap\Conversation· testing · tooling · helper functions
-
Routing ·
-
Caligrafer: every command
- Project · build · data · agents · jobs and tests · maintenance · deploy
- Installation, configuration and Caligrafer
- Routing · Request · Controllers · Views
- Vue: flow of information · routes · validations
- Security and upgrading
- Release notes: 2.26 · 2.25 · 2.24 · 2.23 · 2.22 · 2.21 · 2.20 · 2.19 · 2.18 · 2.17 · 2.16 · 2.15 · 2.14 · 2.13 · 2.12 · 2.11 · 2.10 · 2.9 · 2.8 · 2.7 · 2.6 · 2.5 · 2.4 · 2.3 · 2.1 · October 2026 · changelog
- Testing Caligrafy (contributors)