Within a plugin I have written I would like to route POST requests to the plugin controller and GET requests to a single entity created in craft.
When the user POSTs to http://example.com/start-your-quote it should be handled by the plugin controller. When the user GETs http://example.com/start-your-quote it should load the single entity with the slug 'site-start-your-quote'
I have written the following in the hopes of achieving this:-
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
static function (RegisterUrlRulesEvent $event) {
$event->rules['POST start-your-quote'] = 'craft-lp-api-helper/lpapi';
$event->rules['GET start-your-quote'] = 'site-start-your-quote';
}
);
The POST is working as expected, however the GET results in the following error:-
Blockquote HTTP 404 – Not Found – yii\web\NotFoundHttpException Page not found. ↵ Caused by: Invalid Route – yii\base\InvalidRouteException Unable to resolve the request "site-start-your-quote".
Hopefully I am missing something simple and someone can point me in the righ direction?