I have a need to temporarily redirect my website to a static version hosted on Cloudflare. The current site is a Wordpress site hosted at Ionos and Wordpress seems to be doing a 301 redirect from mydomain.com
to www.mydomain.com
. I would like to be able to continue to access the Wordpress instance by going to www.mydomain.com
but if I (or anyone else) goes to mydomain.com
I would like to be redirected to static.mydomain.com
.
I put this in my .htaccess
file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteCond %{HTTP_HOST} !^www.mydomain.com
RewriteRule ^(.*) https://static.mydomain.com/$1 [R=302,L]
</IfModule>
However, when I visit mydomain.com
I'm still redirected to www.mydomain.com
so it seems the .htaccess RewriteRule isn't getting triggered and so Wordpress is doing its redirect.
Is there some way in .htaccess (I don't have access to the Apache configuration file) to force a redirect like I'm describing?