WordPress.org

Ready to get started?Download WordPress

Forums

Don't save fully qualified domains in the database (7 posts)

  1. the_g_bomb
    Member
    Posted 4 years ago #

    I think siteurl (and home if really necessary although a relative link could be better), would sit better in the wp-config.php file.

    That would do away with the need for the find and replace task when moving between development sites and live versions or when moving the domain of a site in general.

    At the moment if I want to bring to my development site the latest data, instead of just doing and mysqldump or export from phpmyadmin and uploading the file to my dev server, I have to do a find and replace step to take out example.com and replace it with dev.example.com, then do the import. IMHO this adds an unnecessarily complex and potentially error inducing step to the proceedings.

    When I am finished my testing I then have to do the same process to move the data back again.

    If the siteurl was set in the wp-config.php file all guid links in wp-posts could be relative to the baseurl and the siteurl variable could be added as required.

  2. Joe Hall
    Member
    Posted 4 years ago #

    Or you could just change it in wp-admin/options-general.php and hit "Save Changes" before you export and move your SQL. Thats what I do. Just be mindful that after hitting "Save Changes" everything will go wonky until you move to the new domain.

  3. the_g_bomb
    Member
    Posted 4 years ago #

    Doesn't help, when you are trying to maintain a development version and a live version.

    The minute you change it in wp-admin/options-general.php in your development server it goes wonky, but you can get you live site up and running. All good.

    When you try to get you development version running again to do some more testing and changing you have manually edit the database or export and find and replace and re-import.

    Or scenario 2, you want your development version to have the latest version of the site, with logs and comments, but you can't change the setting in wp-admin/options-general.php because you live site will go wonky.

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    Lemme make sure I'm following....you are moving from dev version to live version right?

    You DL the database from dev version

    Then you change the URL at dev version. DL the DB again after name change.

    Upload the DB with the URL change to the live site

    Upload the DB version from before the URL change back to the dev version, that gets all your old settings back

    Both work, nothing is wonky

    Maybe I'm misunderstanding......

    ANd obviously if you are moving DB from live to dev, you do the same thing...the other way

  5. the_g_bomb
    Member
    Posted 4 years ago #

    Don't get me wrong, I realise that its not that difficult, however I just think that it could be simpler. For example it could be possible to just mysqldump the database or export from phpmyadmin and just upload it to the other site. No need to export/import twice and change settings in between.

    And going back the way would be just as easy. If the live site is running and I want my local copy to be current (with the latest changes in the database), I don't really like the idea of changing my url settings even if it is only for the short time it takes to export the database, change the settings and export again and then replace the original database. The live site will still have to go offline for that period.

    If the urls are relative there is no requirement to download, change settings, download again, upload back to the dev database and uploading to live, just download and upload in either direction. The ability to set the URL is already in wp-config.php as of version 2.2.

    define('WP_HOME','http://example.com');
    define('WP_SITEURL','http://example.com');

    My suggestion was to leave them out of the database, the wp-config file has to be edited anyway to put in the db connection details so no major change there just 2 extra lines that need to be put in. The guid in wp-posts could just be /sample-post/ and have WP_HOME appended to the beginning.

  6. chidge
    Member
    Posted 4 years ago #

    I agree actually, this would be very useful. But the easiest way around this - in my opinion anyway, is to develop on a faux live site.

    Change your computers host file to point the live domain to the test install. If you are using a PC you will need to flush the DNS cache, but it is really easy on either a PC or a Mac.

  7. raymor
    Member
    Posted 3 years ago #

    You have the same problem if your site is accessible via https,
    or uses cookies and is accessible as http://www.site.com and site.com,
    and with PHP sessions, and with load balancing such as www1.site.com
    and www2.site.com, and a dozen other things.
    Requiring the use of fully qualified URLs just really screws up
    a lot of things.

    On the other hand, it does help your Google rank, but only
    in the land of fairy tales. In the real world, Google already
    assumes that http://www.site.com and site.com are the normally the same.
    So the actual benefit is .. nothing. Just a huge pain in the
    rear, causing all sorts of incompatibilies, for no reason at all.

Topic Closed

This topic has been closed to new replies.

About this Topic