generalwordpress-multisite

Configure blogs for different domains with different SSL certificates

This section assumes:

  • You have a working WordPress Multisite installation
  • Your server has a static IP address
  • You are able to log in to your server console using a tool like PuTTY (Windows) or SSH (Linux and Mac OS X)
  • You own at least one custom domain name for which you can configure DNS settings
  • You have defined your primary domain and blog as described here and you are able to log in to the WordPress Multisite dashboard.
  • You have added one or more WordPress Multisite blogs with different domains as described here .

Follow these steps:

  • In order to set different SSL certificates for each new domain, configure each domain as a virtual host. Edit the /opt/bitnami/apache/conf/vhosts/wordpress-https-vhost.conf file and add a new virtual host for each new domain. The following code could be taken as an example:

      <VirtualHost 127.0.0.1:443 _default_:443>
        ServerName yourserverdomain.com
        ServerAlias *.yourserverdomain.com
        SSLEngine on
        SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/new_server.crt"
        SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/new_server.key"
        DocumentRoot /opt/bitnami/wordpress
        <Directory "/opt/bitnami/wordpress">
          Options -Indexes +FollowSymLinks -MultiViews
          AllowOverride None
          Require all granted
          # BEGIN WordPress fix for plugins and themes
          # Certain WordPress plugins and themes do not properly link to PHP files because of symbolic links
          # https://github.com/bitnami/bitnami-docker-wordpress-nginx/issues/43
          RewriteEngine On
          RewriteRule ^bitnami/wordpress(/.*) $1 [L]
          # END WordPress fix for plugins and themes# BEGIN nip.io redirection
          RewriteEngine On
          RewriteCond %{HTTP_HOST} ^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(:[0-9]{1,5})?$
          RewriteRule ^/?(.*) %{REQUEST_SCHEME}://%1.nip.io%2/$1 [L,R=302,NE]
          # END nip.io redirection# BEGIN WordPress Multisite
          # Using subdomain network type: https://wordpress.org/support/article/htaccess/#multisite
          RewriteEngine On
          RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
          RewriteBase /
          RewriteRule ^index\.php$ - [L]
          # add a trailing slash to /wp-admin
          RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
          RewriteCond %{REQUEST_FILENAME} -f [OR]
          RewriteCond %{REQUEST_FILENAME} -d
          RewriteRule ^ - [L]
          RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
          RewriteRule ^(.*\.php)$ $1 [L]
          RewriteRule . index.php [L]
          # END WordPress Multisite
        </Directory>
        Include "/opt/bitnami/apache/conf/vhosts/htaccess/wordpress-htaccess.conf"
      </VirtualHost>
    

    Remember to change the ServerName and ServerAlias directives to the correct values.

    To specify a different SSL certificate for each domain, update the paths to the corresponding certificate files in the SSLCertificateFile and SSLCertificateKeyFile directives.

  • After ensuring that the certificates are properly generated and configured in the /opt/bitnami/apache/conf/vhosts/wordpress-https-vhost.conf file, restart Apache to apply the changes.

      $ sudo /opt/bitnami/ctlscript.sh restart apache
    
Last modification February 9, 2023