How do I create an advanced route with multiple slugs? I'm trying to create a route for an RSS feed which allows for the following routes. 

domain/feed
domain/category/feed
domain/category/subcategory/feed


I have the first two routes working and the category fetching logic looks okay to me.

So far in my routes file I have the following

'feed' =&gt; 'feed/_index.twig',
'(?P&lt;slug&gt;[^/]+)/feed' =&gt; 'feed/_index',

// Additional New route
'(?P&lt;slug&gt;[^/]+)/(?P&lt;slug&gt;[^/]+)/feed' =&gt; 'feed/_index',


That last line was added recently as I thought the child category would include the parent category in its route.

I either get a 404 error without that new route, or when I do add that third route I get the following error

preg_match(): Compilation failed: two named subpatterns have the same    
name at offset 27 (craft/app/etc/web/UrlManager.php:387)


Any help would be greatly appreciated.
Brad nails the problem in his comment:


  The error is because you've got two named subpatterns with the same name (&lt;slug&gt;)


And the solution is simple... Change the name(s) of your subpattern(s).

The term slug is just a convention of Craft. It doesn't matter what the names are, they can be anything useful to you:

(?P&lt;domain&gt;[^/]+)/(?P&lt;category&gt;[^/]+)/feed


Whatever values match those named patterns are automatically passed into the Twig template as "magic" variables. So your Twig template can now make use of the domain and category values.