2

I have a live Magento in development. I am connecting to that site by typing the IP address of the site.

Now, I just want to make sure if I edit core_config table and switch the base_url and secure base_url from the IP adress to a domain name (123.123.123.123 > example.com) and redirect domain name servers to my name servers site, this will work right?

I'm asking this because i'm confused. Last time I moved Magento from local to live the backend pages were broken. Will it work? Or are there any things that I must prepare?

1
  • also check cookie domain at core_config_data
    – Amit Bera
    Commented Feb 27, 2015 at 12:47

1 Answer 1

5

If you specify your store code setup in app/etc/local.xml and remove the store URLs from the core_config table of the database then you can easily run the same DB on localhost and remote.

Add a 'default' section to app/etc/local.xml, this section being inside 'config'

<default>
    <web>
        <unsecure>
            <base_url><![CDATA[http://local.localtest.me/]]></base_url>
            <base_web_url>{{unsecure_base_url}}</base_web_url>
            <base_link_url>{{unsecure_base_url}}</base_link_url>
            <base_js_url>{{unsecure_base_url}}js/</base_js_url>
            <base_skin_url>{{unsecure_base_url}}skin/</base_skin_url>
            <base_media_url>{{unsecure_base_url}}media/</base_media_url>
        </unsecure>
        <secure>
            <base_url><![CDATA[https://local.localtest.me/]]></base_url>
            <base_web_url>{{secure_base_url}}</base_web_url>
            <base_link_url>{{secure_base_url}}</base_link_url>
            <base_js_url>{{secure_base_url}}js/</base_js_url>
            <base_skin_url>{{secure_base_url}}skin/</base_skin_url>
            <base_media_url>{{secure_base_url}}media/</base_media_url>
        </secure>
    </web>
</default>

Use that just on your localhost and take the local.xml file out of version control. On the live server replace the URLs given above to the live ones.

Now in your db you will need to remove the keys in core_config_data for base_url etc.

At runtime the settings will be merged into one huge configuration object that gets cached.

3
  • Interesting thought here. How would this work with a multi site setup? Like a second website on a different domain?
    – 7ochem
    Commented Mar 10, 2015 at 14:43
  • You can specify everything on a per store basis. Therefore ti can be done on a multi-store. Commented Mar 10, 2015 at 15:04
  • Yes, I found this question of yours to sort out how to do this per website/store ;) magento.stackexchange.com/q/45649/3326 Thanks!
    – 7ochem
    Commented Mar 10, 2015 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.