Mobile app version of vmapp.org
Login or Join
Karen161

: 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

@Karen161

Posted in: #301Redirect #Htaccess #Https #Redirects

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:

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen161

1 Comments

Sorted by latest first Latest Oldest Best

 

@Holmes151

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>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme