<p><strong>Update</strong> I was able to solve <em>half of</em> my Problem:</p>

<p>Seems the Regex didn't like the "pure" slashes <code>/</code> in the URL between the parameters, once I escaped those, through backslashes like this: <code>\/</code> it no longer gave me a <code>yii\base\InvalidRouteException</code>.</p>

<p>The new Problem I have now is that it can't find the action I'm referring to, see below:</p>

<pre class="lang-php prettyprint-override"><code>// Path of File: ./src/Expedweather.php; in EVENT_REGISTER_SITE_URL_RULES

$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';

// Exert from ./src/controllers/DefaultController:
protected $allowAnonymous = ['index', 'forecast-panel'];
...
public function actionForecastPanel() {...}

</code></pre>

<p>An additional piece of info: I'm able to route to the DefaultController's index Function by removing <code>/forecast-panel</code> from the target action.</p>

CC BY-SA 4.0
2019-09-10T07:22:18.500Z
2019-09-10T07:22:18.500Z
Campiotti
<p>I'm updating a Craft 2 plugin to Craft 3 and I'm having difficulties getting the Regex URLs working correctly. The eocs I'm using: <a href="https://docs.craftcms.com/v3/extend/updating-plugins.html#plugin-hooks" rel="nofollow noreferrer">Craft3 Docs</a> <br>
I used <code>pluginfactory.io</code> to create the basic craft3 plugin scaffold.
<br> For context: the plugin name is <code>expedweather</code>.</p>

<p>This is the Route I'm trying to register:</p>

<pre class="lang-php prettyprint-override"><code>$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/forecastPanel';
</code></pre>

<p>In my DefaultController.php I've got this:</p>

<pre class="lang-php prettyprint-override"><code>protected $allowAnonymous = ['index', 'forecast-panel'];
</code></pre>

<p>And I'm not sure what I'm doing wrong here but All I get is</p>

<blockquote>
  <p>HTTP 404 – Not Found – yii\web\NotFoundHttpException Page not found. ↵
  Caused by: Invalid Route – yii\base\InvalidRouteException</p>
</blockquote>

<p><strong>I've made sure the plugin is enabled in the backstage.</strong></p>

<plugin-development><craft3><plugins><routing><migration>
Plugin RegisterUrlRulesEvent - Regex URL-Routing gives 404
# Plugin RegisterUrlRulesEvent - Regex URL-Routing gives 404

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

I'm updating a Craft 2 plugin to Craft 3 and I'm having difficulties getting the Regex URLs working correctly. The eocs I'm using: Craft3 Docs 
I used pluginfactory.io to create the basic craft3 plugin scaffold.
 For context: the plugin name is expedweather.
This is the Route I'm trying to register:
$map_page = 'data////';
$event->rules[$map_page] = 'expedweather/forecastPanel';

In my DefaultController.php I've got this:
protected $allowAnonymous = ['index', 'forecast-panel'];

And I'm not sure what I'm doing wrong here but All I get is

HTTP 404 – Not Found – yii\web\NotFoundHttpException Page not found. ↵
  Caused by: Invalid Route – yii\base\InvalidRouteException

I've made sure the plugin is enabled in the backstage.

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


---

## 1 answers

### Answer by username_0 on 2019-09-10. Score: 1 | Accepted answer

Update I was able to solve half of my Problem:
Seems the Regex didn't like the "pure" slashes / in the URL between the parameters, once I escaped those, through backslashes like this: \/ it no longer gave me a yii\base\InvalidRouteException.
The new Problem I have now is that it can't find the action I'm referring to, see below:
// Path of File: ./src/Expedweather.php; in EVENT_REGISTER_SITE_URL_RULES

$map_page = 'data\/\/\/\/';
$event->rules[$map_page] = 'expedweather/forecast-panel';

// Exert from ./src/controllers/DefaultController:
protected $allowAnonymous = ['index', 'forecast-panel'];
...
public function actionForecastPanel() {...}


An additional piece of info: I'm able to route to the DefaultController's index Function by removing /forecast-panel from the target action.


---

