So I have a webserver running on Apache, with a few virtual hosts. I want to default to https and hence I have a rewrite rule. <VirtualHost *:80>       ServerName example.com       ServerAlias example.com www.example.com       RewriteEngine on       ReWriteCond %{SERVER_PORT} !^443$       RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] </VirtualHost>The interesting thing is that, I always see multiple 301 happening. iehttp://example.com/something -> https://example.com/something -> https://www.example.com/something I thought it might be the ServerAlias that is causing the issue, so I split the conf to 2 separate rules<VirtualHost *:80>       ServerName example.com       RewriteEngine on       ReWriteCond %{SERVER_PORT} !^443$       RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] </VirtualHost><VirtualHost *:80>       ServerName www.example.com       RewriteEngine on       ReWriteCond %{SERVER_PORT} !^443$       RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] </VirtualHost>Still getting the same result. I don't have any rules anywhere to redirect to www, user enters example.com and without www, and I'm confused where does the second redirect come from.I also don't have any .htaccess rules to perform redirects. What am I doing wrong here ?Edit : Problem identified as a wordpress plugin doing the redirect. Thanks for hints from community.
Why does apache redirect to www without RewriteRule
htaccess;redirects;mod rewrite;url rewriting;apache2
From the redirect, it looks like this could be happening in the VirtualHost container for port 443.Failing that, the redirect could be happening in the website code itself. (Which appears to be the case here - a WordPress plugin).