I have 2 web applications which are on different hosts. The main one (example.com) is on another hosting with domain connected to it, the second one (sub.example.com) is a wordpress website on DigitalOcean. For this, in the dns manager I created an A record which is pointing to ip of the DigitalOcean Droplet. After that, I setted the wordpress application with the desired subdomain and added SSL certificate for the subdomain in droplet.
The connection is working fine, when I’m accessing sub.example.com, it is redirecting to the wordpress website, but if users for the first time type sub.example.com, they are being redirected to https://ip_adress and gets a “ERR_CERT_COMMON_NAME_INVALID”
I tried to add a redirect from ip to subdomain in apache config, but without any result…
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^18\.182\.216\.244$1
RewriteRule ^(.*)$ https://sub.example.com/$1 [L,R=301]
</IfModule>
The .htaccess file:
RewriteRule ^.well-known/(.*)$ - [L]
#END Really Simple SSL LETS ENCRYPT
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^18\.182\.216\.244$1
RewriteRule ^(.*)$ https://sub.example.com/$1 [L,R=301]
</IfModule>
WP_HOME and WP_SITEURL are:
define( 'WP_HOME', 'https://sub.example.com' );
define( 'WP_SITEURL', 'https://sub.example.com' );
What can I do to solve this issue ?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!