: Redirect http www and non-SSL domains to HTTPS without multiple redirects? I'm losing link juice in multiple redirects. I need to redirect all domain versions to my default domain i.e. https://example.com
I'm losing link juice in multiple redirects.
I need to redirect all domain versions to my default domain i.e.
example.com
By all domain versions I mean www, , www and . (index.php for all.)
I am currently using the code below. All domains are redirecting to but not directly. If I type www, it will be redirected 3 times as in the picture. I still need to redirect index.php.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ example.com/ [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ %{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
I am using "Redirect Path" extension of Google Chrome browser to monitor the redirects.
You can see redirect 3 times:
You can see redirect 2 times:
More posts by @Karen161
1 Comments
Sorted by latest first Latest Oldest Best
Try using more VirtualHosts and redirecting instead of doing rewrites.
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com Redirect permanent / www.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com Redirect permanent / example.com/ ...
(put your HTTPS config & path to certs here for the redirect to work)
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
...
(This is your destination VirtualHost)
</VirtualHost>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.