![]() Parameters string $route A string describing the template of the route array $url An URL to redirect to. As you can remap URLs and not loose any passed args. This is useful with greedy routes, routes that end in * are greedy. persist Passes the params to the redirected route, if it can.status Sets the HTTP status (default 301). ![]() Redirects /posts/* to with a HTTP status of 302 Options: Using an array as the redirect destination allows you to use other routes to define where an URL string should be redirected to. Redirects /home/* to /posts/view and passes the parameters to /posts/view. The redirection can occur within your application or redirect to an outside location.Įxamples: $routes->redirect('/home/*', ) Redirection routes are different from normal routes as they perform an actual header redirection if a match is found. Redirect() source public redirect( string $route, array $url, array $options )Ĭonnects a new redirection Route in the router. Also contains additional parameters such as which routed parameters should be shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a custom routing class. array $options optional Īn array matching the named elements in the route to regular expressions which that element should match. These parameters will be used by default and can supply routing parameters that are not dynamic. Parameters string $route A string describing the template of the route array $defaults optional Īn array describing the default route parameters. POST requests will fail to match this route. ![]() The above route will only be matched for GET requests. _method Only match requests with specific HTTP verbs.Įxample of using the _method condition: $routes->connect('/tasks', )._ext is an array of filename extensions that will be parsed out of the url if present.If undefined a name will be generated for each connected route. This can be used to optimize reverse routing lookups. _name is used to define a specific name for routes.multibytePattern Set to true to enable multibyte pattern support in route parameter patterns.You can override persistent parameters by redefining them in a URL or remove them by setting the parameter to false. persist is used to define which route parameters should be automatically included when generating new URLs.routeClass is used to extend and change how individual routes parse requests and handle reverse routing, via a custom routing class. ![]() Adding a parameter to pass will remove it from the regular route array. pass is used to define which of the routed parameters should be shifted into the pass array.$options offers several 'special' keys that have special meaning in the $options array. Patterns for routing parameters do not need capturing groups, as one will be added for each route params. Shows connecting a route with custom route parameters as well as providing patterns for those parameters. And providing routing parameters for a static route. The above shows the use of route parameter defaults. The '/*' syntax makes this route greedy in that it will match requests like /posts/index as well as requests like /posts/edit/1/foo/bar. The first parameter will be used as a controller name while the second is used as the action name. At their core routes are a set or regular expressions that are used to match requests to destinations.Įxamples: $routes->connect('/:controller/:action/*') Routes are a way of connecting request URLs to objects in your application. Connect() source public connect( string $route, array $defaults, array $options ) I have some problem using ajax, please help me. ![]()
0 Comments
Leave a Reply. |