I want to make a route that catches all "php" files... I've tried:
routes.MapRoute("php", "{*x}.php", new { controller = ... });
But I get the following exception:
A path segment that contains more than one section, such as a literal section
or a parameter, cannot contain a catch-all parameter.
Parameter: routeUrl
It must catch:
/p1/p2/p3.php
/p1/p2.php
/p1.php
I want to write a single rule that can catch N
levels... How can I do that?
Using a routing system allows us to structure our application in a better way instead of designating each request to a file. A routing system works by mapping an HTTP request to a request handler based on the request method and path specified in the URL of the request.
Accessing The Current RouteThe Route::current() method will return the route handling the current HTTP request, allowing you to inspect the full Illuminate\Routing\Route instance: $route = Route::current(); $name = $route->getName();
In order to catch the current route, you can use $this->request->get['route']; in the catalog/controller/common/header.
You can use a constraint:
routes.MapRoute("php", "{*allphp}", new { ... }, new { allphp = @".*\.php" });
If you still have the default route, this must be placed before.
My answer is based upon: Make routing ignore requests for a file extension
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With