davidyell / seo-redirector
Installs: 3 330
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.2
Requires (Dev)
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^3.3
This package is auto-updated.
Last update: 2024-01-16 02:00:23 UTC
README
A small library for matching a url and finding a redirect, with an http code.
Matching urls
An array of redirects is required. With the key being the url to redirect, and the value
being an array of target
and `code.
You can use a direct match
// Direct matching $redirects = [ '/examples/first' => [ 'target' => '/tutorials/first', 'code' => 301 ] ];
You can use a slug match
// Slug matching $redirects = [ '/examples/:slug/first' => [ 'target' => '/tutorials/:slug/first', 'code' => 301 ], 'examples/:slug' => [ 'target' => '/tutorials/:slug', 'code' => 302 ] ];
You can also use a greedy match
// Greedy matching $redirects = [ '/examples/*' => [ 'target' => '/tutorials', 'code' => 301 ] ];
More examples can be found in the tests.
License
MIT