I thoroughly searched stackoverflow and found about 100 mod_rewrite-questions, but this was not covered...strange as it seems pretty common.
My problem: I have a web-application on a master-domain (mywebapp.com). Now I have additional country-specific TLDs (eg .ch) which I'd like to redirect on the .com-domain. Nothing special so far. But now to the other criteria:
Requirements
- the protocol should be left unchanged
- the query-string should be left unchanged
- the subdomain-part should be left unchanged as the tenants are identified by those
- only exchange the TLD!
Examples
So to put it all together some examples how it should be:
- http:// demo.mywebapp.ch -> http:// demo.mywebapp.com
- http:// other.mywebapp.ch/user/profile -> http:// other.mywebapp.com/user/profile
- https:// third.mywebapp.ch/about -> https:// third.mywebapp.com/about
(spaces in urls are intentional to prevent stackoverflow from generating links)
and so on. I really only need to replace the TLD in protocol-generic manner. Of course it would be nice if the rule-set is SEO-conform (301).
Additional Information / details
The domains are currently set to point to the same webserver/IP which I have root-access upon. The server is managed by ISPConfig, but II can edit the vhosts manually as well.
Thanks already in advance!
cheers, Pascal