I created a fresh install of WordPress using Apache24 (on FreeBSD, not that that should make a difference), say using maindomain.com
. I created an SSL certificate with Let's Encrypt and everything works fine, DNS pointing at my server's IP.
I then enabled the Multisite functionality using subdirectories. I created another site, located at https://maindomain.com/site1
. Everything works correctly, with the different sites using the 2 different themes I installed and activated.
I also created another SSL certificate for site1.com
, and pointed the DNS for that url to my server's IP as well.
I have set up 2 separate Apache configuration files, one for each virtual host, each pointing to the respective SSL certificate files (located in separate directories). At this point everything works correctly (main site and second site in the subdirectory).
Now I can't get site1.com
to work correctly. When I go to the site administration page for site1, into the info tab and change the Site Address (URL)
to site1.com
, navigation to site1.com
redirects me to maindomain.com
.
My .htaccess file is standard:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
My Apache config file (in sites-available, and symlinked to sites-enabled) is also pretty standard:
<VirtualHost *:443>
ServerName www.site1.com
ServerAlias site1.com
SSLEngine on
SSLCertificateFile "/usr/local/etc/letsencrypt/live/site1.com/cert.pem"
SSLCertificateKeyFile "/usr/local/etc/letsencrypt/live/site1.com/privkey.pem"
SSLCertificateChainFile "/usr/local/etc/letsencrypt/live/site1.com/fullchain.pem"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
BrowserMatch "MSIE [2-5]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
CustomLog "/var/log/httpd-ssl_request.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
<Directory "/usr/local/www/apache24/data/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/site1.com.ssl-error.log"
CustomLog "/var/log/site1.com.ssl-access_log" combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.site1.com
ServerAlias site1.com
Redirect permanent / https://site1.com/
</VirtualHost>