Search code examples
tomcatdnsserversubdomain

Typical domain mapping requirement


I have a website hosted to root domain say www.example.com. Can I do the mapping as follows-

www.example.com/portal1 mapped to www.portal1.com
www.example.com/poral2 mapped to www.portal2.com
www.example.com/portal1/product/product1-> www.portal1.com/product/product1
www.example.com/portal2/product/product1-> www.portal2.com/product/product1

Please note that all the urls mentioned on left hand side are working correctly (mapping is done). Portals are variable so there can be n number of such portals.

Thanks in advance for help


Solution

  • It took me lot of RnD to finally arrive to the solution I was exactly looking at. Most of the answers given are partially corrert. However the requirement was very typical and I have solved it in following way.

    I have developed a servlet which checks for host names (valid hostnames are kept in database) and valid url patterns and make appropriate routing. (Server side routing). This also includes checks for how further routing takes place like if somebody visits www.porta1.com and clicks link on it he should land on www.portal1.com/aboutus.

    I know lot of hard work, but works exactly what was needed.