Redirecionei meu domínio para meu servidor e configurei com sucesso o domínio principal assim:
/etc/apache2/sites-available/mywordpress.com.conf
<VirtualHost *:80>
ServerName www.mywordpress.com
ServerAlias mywordpress.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mywordpress.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine off
RewriteCond %{SERVER_NAME} =mywordpress.com [OR]
RewriteCond %{SERVER_NAME} =www.mywordpress.com [OR]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
<Directory /var/www/mywordpress.com/public_html>
AllowOverride All
</Directory>
</VirtualHost>
então tento configurar meu subdomínio assim:
/etc/apache2/sites-available/app.mywordpress.com.conf
<VirtualHost *:80>
ServerName app.mywordpress.com
ServerAlias www.app.mywordpress.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/app.mywordpress.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
eu já executo a2ensite app.mywordpress.com.conf && service apache2 restart
mas quando acesso meu subdomínio ele ainda me redireciona para meu domínio principal
tento configurar meu domínio principal .htaccess assim:
/var/www/mywordpress.com/public_html/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
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
# redirect to https www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)(mywordpress\.com)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
# redirect to http subdomain
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^((?!www).+\.app.mywordpress\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
mas ainda não está funcionando