Defining www for new server and switching from non-www


#1

Hi,
I am currently developing a website not using www on .test and the staging server is just the ip address, but for the the production server I want to use www.
Another scenario is when I would like to change a live site from non-www to www.

I find the instructions a little lacking on the www aspect, and I see that some have issues with SSL when server is provisioned with incorrect www settings, so I just though i’d check to make sure I had it right.

Is this the settings below all that is required? And then when I migrate the DB from the staging site i just make sure to replace the ip address with the domain name (should it be the www or the non-www in the db replace?):

wordpress_sites:
  domain.org:
    site_hosts:
      - canonical: domain.org
        redirects:
          - www.domain.org
    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@github.com:notechup/nncc-site.git # replace with your Git repo URL
    repo_subtree_path: site # relative path to your Bedrock/WP directory in your repo
    branch: master
    multisite:
      enabled: false
    ssl:
      enabled: true
      provider: letsencrypt
    cache:
      enabled: true
      duration: 30s
    env:
      wp_env: production
      wp_home: https://www.domain.org
      wp_siteurl: https://www.domain.org/wp

#2

If your canonical domain is without www, then I’d go without it for your wp_home and wp_siteurl as well.

The config you have there will redirect www.domain.org to domain.org.

But yes in general that’s all the configuration you need (and all that’s available). If you ever have a WP database you’re copying to another environment, you’ll need to search/replace domain strings as you said.


#3

For the search and replace, WP Migrate DB is the way to go https://wordpress.org/plugins/wp-migrate-db/

You can do find and replace as part of the export from local/staging to live,
eg //domain.test -> //domain.org