Yii 2 canonical URL in urlManager configuration
<p>I've got <code>urlManager</code> section in app configuration with several URLs per route:</p>

<pre><code>    'urlManager' =&gt; [
        'enablePrettyUrl' =&gt; true,
        'showScriptName' =&gt; false,
        'enableStrictParsing' =&gt; true,
        'rules' =&gt; [
            'article-a' =&gt; 'article/a', // canonic comes first
            'article-deprecated-a' =&gt; 'article/a',
            'article-another-a-is-deprecated' =&gt; 'article/a',
            'b-annoucement' =&gt; 'announcement/b', // canonic comes first
            'legacy-b-annoncement' =&gt; 'announcement/b',
            ...
</code></pre>

<p>SEF URLs for routes are stored in <code>frontend/config/main.php</code> as an array, with multiple URLs per route. The first URL for the given route (i.e. <code>/article-a</code>) is canonical and the rest are legacy URLs.</p>

<p>What's the most natural way to specify canonical URL for a group of URLs that are pointing to the same route? It can be either <code>rel="canonical"</code> in view or 301/302 redirect to canonical URL.</p>

<p>Canonical URLs should be preferably specified in a place where the routes were defined (<code>frontend/config/main.php</code> configuration file in this case). <strong>The requirement here is that canonical URL should be defined outside of the controller, not hard-coded to controller.</strong></p>