Reputation: 6455
I'm wondering what the best way for me to do this would be, i.e. routing any request with '.php' to the root path..
I've looked through the docs and can find plenty on wildcard routes, but little / nothing on conditional routes. Is there a way for me to do this in the config/routes file? Or would I need to set up a redirect in the controller based on the format of the request?
Thanks in advance.
Upvotes: 0
Views: 42
Reputation: 44962
You can definitely do a redirection from the routes file.
It would look something like:
get '*.php', to: redirect('/'), format: false
The format: false
ignores the extension as a determinant for content type (e.g. HTML, JSON).
Upvotes: 1
Reputation: 2030
Here is a way to do it, not sure if the best one though.
get '*path.php', to: redirect('/')
Upvotes: 0