• I began my self hosted WordPress project on a LAMP server on my home network with the intention of migrating it to a server in the cloud. I began with home and site URL’s specified as “localhost” and updated it to the IP address on my home network to try connections from other devices on my LAN. I discovered that updating the address on either the General settings or in wp-config that the address of the image file used on my theme header was not updated. There may have been other components that also did not reflect the change of home or site url.

    Is there a way to change the host URL name of a WordPress project so that it can be easily migrated to different machines using different IP address or URL’s?

    My work around was to use a LAMP server in the cloud with a fixed IP address that could be referenced by a domain name I registered. It seems to me this plan will work fine if I move my project to a new server as long as I always keep the same domain name. But it prevents me from developing WordPress projects in a stand alone environment using the “localhost” name if I ever plan to migrate the project to the internet.

    I’d appreciate any advice, suggestions, or referral to reference material. Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The theme and plugins should always use WordPress functions to get the URL, so the only places that might have it hard-coded would be content or options. There are many migration plugins that change the content and options for you when you are moving to a differently named site.

    Thread Starter jgstroup

    (@jgstroup)

    Thank you Joy. Yes – I was expecting the WordPress theme to pull the URL for the image header from the database – to allow easily migrating to a new location by simply changing the site and home URL settings in the WordPress general settings. Unfortunately, the theme keeps the header image URL in a separate table record and is unchanged when changing the home and site URL in the general settings.

    I considered writing some SQL code that updated all the locations in the database that stored the URL – and I could as a last resort. But it seemed to me that there ought to be an easier way. After all – that’s why the home and site URL settings in the general setting exist.

    Alas – even hard coding the site and home URLs in the wp-config file didn’t change the address of the theme’s header image URL.

    You may be right about using a plug-in. But I wonder how much standardization themes have that would make such a plug-in possible. Without standardization, I suppose each theme could support migration by having it’s own version of general settings that allow the user to update to the new URL.

    By the way – I once make a typo when entering the IP address of the home and site URL. This locked me out of the site without hard coding the proper IP address in the wp-config file to override my error. When hard coding the URL in the wp-config file, the general settings “greys out” the URL fields. So the only way I found to fix this properly was to go into the wordpress SQL database and correct my error in the appropriate field there. Not too difficult – but for someone unfamiliar with SQL and how to make updates directly to the database, it would have been an disaster.

    Thread Starter jgstroup

    (@jgstroup)

    Thinking more about this later in the day, I recalled that when media is uploaded, WordPress stores the location address of the media files in the database using the URL set in the home and site URL. This might actually be the problem I was having with the header image in the Theme on my WordPress site. These database field are not changed with the host and site URL is changed on the General Settings page.

    This all might not be a problem if WordPress used relative addressing – and maybe it does, I just haven’t figured out how to use it yet.

    It doesn’t. WordPress has always stored things as full complet URL’s.

    If you’re moving a site, or changing domain names, the best thing is to use a search and replace plugin. There’s a lot out there, and they will let you change things like that easily and without breaking stuff (mostly).

    These database field are not changed with the host and site URL is changed on the General Settings page.

    No, they are not changed. That’s why you use a migration plugin which will change the domain name in all the content and options (theme or core or plugin) for you. You don’t have to know Regular Expressions and think of where all the URLs might be with a search/replace, and it handles the options which are serialized (they are stored with a leading length, so you have to change the number also).

    This all might not be a problem if WordPress used relative addressing

    WordPress can’t use relative addresses because the pages are dynamic. The CSS, JS, images, etc. must be loaded from absolute URLs because every dynamic page has a different URL, which can also change at any time.

    Thread Starter jgstroup

    (@jgstroup)

    Thank you CATACAUSTIC,bg for your kind response. I was hoping I had missed out on some element of documentation that might allow me to easily develop a WordPress site on a stand alone machine using “localhost” and then migrating it to a server when time to deploy. It appears this is not easily accomplished.

    In fact, much of the WordPress documentation and tutorials use the example of using “localhost” in lieu of a domain name. It seems to me that this is a Red Herring and a disservice to new WordPress users.

    As it happens getting a shared server in the cloud (with a static IP address needed for a domain name) for development is straightforward and inexpensive – and only moderately less convenient than using a stand along computer. The issues only remain are the selection of the domain name on the final deployment – and the expense involved in registering the domain name.

    It would have saved me some time had I known that at the beginning.

    • This reply was modified 5 years, 1 month ago by jgstroup.

    The built-in Export/Import tools (they are just plugins by the dev team) use the XML format for moving content. It actually does change the URLs when you use it, except that the new editor has some data attributes on some things that are not handled. But it is mostly about content, and not options, so it’s not migration.

    Thread Starter jgstroup

    (@jgstroup)

    Thank you Joy – yes, that matches my experience using the Export/Import plug-ins. In fact that’s how I came to discover the limitations.

    Since I had the original media files, I tried just doing the Export/Import of the posts and pages, and the re-loading the media files on the new site. Oddly, some of my jpeg files were referenced properly, and some weren’t.

    Also – I had several places where I created links to other pages or posts within my site. These hyperlinks don’t update.

    I got into this because I wanted to move a WordPress site I developed on wordpress.com to my own host to have free reign on development. Its been quite a chore getting it all moved.

    What I do @jgstroup, is to configure my localhost webserver to use the “VirtualHost” method, then with the “hosts” file direct my domain name to localhost, by commenting the lines in the hosts file on or off I can rapidly switch between web hosted and localhost servers if required.

    I usually go to the trouble of making the database name and database user the same as will work in my hosting, thus even the wp-config.php file migrates unchanged.
    With the exception of SSL and services such as SMTP for sending email, my websites barely know that they have been moved between localhost and hosted.
    I have never bothered with SMTP on localhost, I just leave that till it is hosted.
    I have gone to the trouble of self signing an SSL certificate and configuring the security exception in he browsers.

    In fact, much of the WordPress documentation and tutorials use the example of using “localhost” in lieu of a domain name. It seems to me that this is a Red Herring and a disservice to new WordPress users.

    I totally agree.

    Links to useful documents include:
    https://en.wikipedia.org/wiki/Hosts_(file)
    https://httpd.apache.org/docs/current/vhosts/
    https://httpd.apache.org/docs/current/vhosts/name-based.html

    • This reply was modified 5 years, 1 month ago by RossMitchell.
    • This reply was modified 5 years, 1 month ago by RossMitchell.
    Thread Starter jgstroup

    (@jgstroup)

    Thank you RossMitchell – Your documentation links are helpful.

    Until WordPress provides greater flexibility in changing the host/site name, the only real caveat is that a developer needs to know the eventual domain name for the blog.

    I’m sure it’s only one of the WordPress “gotchas” for a new user to look out for. The silver lining is that dealing with such problems requires a new user to look deeper “under the hood.”

    It’s a technical detail that might perhaps be unnecessary for a new wordpress.com user – but surely something for a new self hosting user to keep in mind.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘changed home url not reflected in theme header image’ is closed to new replies.