Im not entirely sure what you are trying to achieve. Are you looking for two different routers i.e. two distinct front names, defined from within a single module?. If so, read on - if not, can you clarify things a little further please.
Firstly, you have a tag mismatch in the xml you have provided in Custom Module 2. You are opening <Namespace_Module1>
and closing with </Namespace_Module2>
- so as it stands, this code will not work.
Secondly, to define a router, you must use the <routers>
tag - so there is no issue with this. The nodes directly underneath it must be unique though.
So, assuming I have read your question correctly and you want to merge these two router nodes but still have two distinct front names, the following would work:
<admin>
<routers>
<namespace_module1>
<use>admin</use>
<args>
<module>Namespace_Module1</module>
<frontName>frontname</frontName>
</args>
</namespace_module1>
<namespace_module2>
<use>admin</use>
<args>
<module>Namespace_Module2</module>
<frontName>namefront</frontName>
</args>
</namespace_module2>
</routers>
</admin>
Though, if there was a particular reason that these have to be separate routers, then I would offer the following as better alternative: use a single router but multiple controllers. So your xml would just be:
<admin>
<routers>
<namespace_module>
<use>admin</use>
<args>
<module>Namespace_Module</module>
<frontName>frontname</frontName>
</args>
</namespace_module>
</routers>
</admin>
Create two controllers in your modules controller directory, say Module1Controller.php
and Module2Controller.php
.
Then you would be able to access them (the index actions) via /frontname/module1/
and /frontname/module2
.
This feels like a much cleaner solution.