Installation and setup | laravel-missing-page-redirector-go | Spatie       

 SPATIE  

laravel-missing-page-redirector-go
==================================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-missing-page-redirector-go](https://spatie.be/docs/laravel-missing-page-redirector-go/v1)  Installation and setup

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-missing-page-redirector-go/v1) 

  Installation and setup    
- [ Introduction ](https://spatie.be/docs/laravel-missing-page-redirector-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/laravel-missing-page-redirector-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-missing-page-redirector-go/v1/usage)
- [ Testing ](https://spatie.be/docs/laravel-missing-page-redirector-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-missing-page-redirector-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/laravel-missing-page-redirector-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/laravel-missing-page-redirector-go/v1/support-us)

 Installation and setup
======================

Requires Go 1.27 or newer and Laravel Go `go.laravel.com v0.1.0`.

```
go get github.com/spatie/laravel-missing-page-redirector-go@v0.1.0
```

Install the package explicitly in `bootstrap/app.go`:

```
import (
    "github.com/spatie/laravel-missing-page-redirector-go"
    laravel "go.laravel.com"
)

func Options() laravel.Options {
    return laravel.Options{
        Packages: []laravel.Package{
            redirector.New(func(c *redirector.Config) {
                c.Redirects = redirector.Rules{
                    {From: "/non-existing-page", To: "/existing-page"},
                    {From: "/old-blog/{slug}", To: "/blog/{slug}"},
                }
            }),
        },
    }
}
```

Installing the module alone does not activate it. Registration installs global middleware, so missing routes as well as explicit 404 responses are checked. Unlike PHP, no configuration file needs publishing and no separate middleware append is required.

`Config.Redirects` defaults to no rules, `Config.Redirector` to the configured rules, `Config.StatusCodes` to `[]int{404}`, and `Config.DisableMiddleware` to `false`.

Set `MISSING_PAGE_REDIRECTOR_STATUS_CODES=418,500` to select response codes, `all` for every code or `disabled` for no lookups. An absent or blank value uses 404. Invalid values fail startup. Callbacks passed to `New` run after environment defaults. An empty non-nil `StatusCodes` slice means all, while nil means disabled. This preserves the PHP distinction between an empty array and null.

For fallback-only use, set `DisableMiddleware` to true. Each application receives its own immutable static rule set. Custom redirectors must support concurrent requests.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
