: Why does apache redirect to www without RewriteRule 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
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 example.com RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) %{HTTP_HOST}/ [NC,R,L]
</VirtualHost>
The interesting thing is that, I always see multiple 301 happening. ie example.com/something -> example.com/something -> 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 ^/(.*) %{HTTP_HOST}/ [NC,R,L]
</VirtualHost>
<VirtualHost *:80>
ServerName example.com RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) %{HTTP_HOST}/ [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.
More posts by @Courtney195
1 Comments
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.