I’m currently porting a website from WordPress to CakePHP, and I have a problem with one of the routes used in the WP version.
I have to route http://example.com/?specific_key=value to http://example.com/controller/action but I can’t find a way to catch the url with the params before the default home page route catches it.
Any advice or pointers are greatly appreciated.
Thanks!
Try adding the following to the top of your routes file. Check if the param is set with the value and connect ‘/’ to where you need it to route to. This way it will match your route before pages controller route.
You could also create a rewrite rule for it in your htaccess file:
Third Option: Use a custom route class: https://gist.github.com/3763800
Create the file
APP/Lib/Route/QueryStringRoute.phpand put the contents of the above link in it.Then in your routes do:
Again, it would need to be before your home route.
Edit: Added third option.