<h1>Found a Solution</h1>
<h3>Context:</h3>
<p>When I created my plugin-frame through <a href="https://pluginfactory.io" rel="nofollow noreferrer">https://pluginfactory.io</a> the <strong>DefaultController was still a thing</strong> -&gt; routing to /pluginname/default-controller-action-name worked as it defaulted to search in the... default-controller. But it seems that is no more, <br>so what I had to do instead to get it to find the action is add a section referring to the controller.</p>
<h3>this is the new/fixed code:</h3>
<pre class="lang-php prettyprint-override"><code>// ./src/Expedweather.php::init
$map_page = 'data\/&lt;range:\w+&gt;\/&lt;peak:\w+&gt;\/&lt;view:\w+&gt;\/&lt;parameter:\w+&gt;';
$event-&gt;rules[$map_page] = 'expedweather/default/forecast-panel'; // &lt;-- changed!!
// ./src/controllers/DefaultController
protected $allowAnonymous = ['index', 'forecast-panel'];
public function actionForecastPanel() {...}
</code></pre>
<p>The only row that changed is the <code>$event-&gt;rules</code> one which now has <strong>/default/</strong> before the action -&gt; this refers to the DefaultController.</p>

CC BY-SA 4.0
2019-09-13T06:47:28.800Z
2019-09-13T06:47:28.800Z
2020-06-17T08:56:27.903Z
Campiotti
<p>The error I'm getting:</p>

<pre>
HTTP 404 – Not Found – yii\web\NotFoundHttpException
Page not found.
↵
Caused by: Invalid Route – yii\base\InvalidRouteException
Unable to resolve the request "Expedweather/forecast-panel".
</pre>

<p>The plugin's base was made through <a href="https://pluginfactory.io" rel="nofollow noreferrer">https://pluginfactory.io</a>, I've simply added to it.</p>

<p>Below are the relevant code excerpts which for some reason do not seem to work as intended.</p>

<pre class="lang-php prettyprint-override"><code>// ./src/Expedweather.php::init
$map_page = 'data\/&lt;range:\w+&gt;\/&lt;peak:\w+&gt;\/&lt;view:\w+&gt;\/&lt;parameter:\w+&gt;';
$event-&gt;rules[$map_page] = 'expedweather/forecast-panel';
// ./src/controllers/DefaultController
protected $allowAnonymous = ['index', 'forecast-panel'];
public function actionForecastPanel() {...}
</code></pre>

<p>Any ideas and/or potential solutions?
The Regex routing seems to work fine, but it cannot find the DefaultController's Action.</p>

<p>This is on CraftCMS Version <code>3.3.0.1</code></p>

<plugin-development><craft3><plugins><migration>
Plugin RegisterUrlRulesEvent - cannot find Controller aciton -> 404
# Plugin RegisterUrlRulesEvent - cannot find Controller aciton -> 404

(Asked by: username_0 on 2019-09-10)

The error I'm getting:

HTTP 404 – Not Found – yii\web\NotFoundHttpException
Page not found.
↵
Caused by: Invalid Route – yii\base\InvalidRouteException
Unable to resolve the request "Expedweather/forecast-panel".

The plugin's base was made through https://pluginfactory.io, I've simply added to it.
Below are the relevant code excerpts which for some reason do not seem to work as intended.
// ./src/Expedweather.php::init
$map_page = 'data\/\/\/\/';
$event->rules[$map_page] = 'expedweather/forecast-panel';
// ./src/controllers/DefaultController
protected $allowAnonymous = ['index', 'forecast-panel'];
public function actionForecastPanel() {...}

Any ideas and/or potential solutions?
The Regex routing seems to work fine, but it cannot find the DefaultController's Action.
This is on CraftCMS Version 3.3.0.1

**Tags:** plugin-development, craft3, plugins, migration

---

## 1 answers

### Answer by username_0 on 2019-09-13. Score: 0 | Accepted answer

Found a Solution
Context:
When I created my plugin-frame through https://pluginfactory.io the DefaultController was still a thing -> routing to /pluginname/default-controller-action-name worked as it defaulted to search in the... default-controller. But it seems that is no more, so what I had to do instead to get it to find the action is add a section referring to the controller.
this is the new/fixed code:
// ./src/Expedweather.php::init
$map_page = 'data\/\/\/\/';
$event->rules[$map_page] = 'expedweather/default/forecast-panel'; // <-- changed!!
// ./src/controllers/DefaultController
protected $allowAnonymous = ['index', 'forecast-panel'];
public function actionForecastPanel() {...}

The only row that changed is the $event->rules one which now has /default/ before the action -> this refers to the DefaultController.


---

