Search code examples
phpdnsnameservers

Merging domain extensions of .com and .in but displaying .com in the URL Bar


I am developing a web application and have bought two domain names xxx.com and xxx.in. While coding for the new website, I have been using xxx.in, while keeping xxx.com for the old website. During the coding process, I have hardcoded xxx.in in some places. Now that my new website is ready for deployment, I want to change its domain to xxx.com. It would be better if there is some sort of redirect from .in to .com so that the user gets to see only .com in the URL bar while allowing my codes to run perfectly. Is this possible by just creating an A Rule in my host? How should I proceed in such a situation?


Solution

  • You should proceed by either:

    Option 1: fast and easy (but not optimal) -

    Use search and replace to turn all instances of 'xxx.in' to 'xxx.com'

    Option 2: the better way to go -

    Use search and replace to turn all instances of 'xxx.in' to some kind of helper function to retrieve a configuration value for your domain. For example:

    MyHelper::getConfig('baseUrl');
    

    ... or similar

    Then, create your helper class and the necessary functions to grab this configuration value out of your database.