Mobile app version of vmapp.org
Login or Join
BetL925

: How to approach 3 different redirects at the same time So this is the scenario, I have already placed some 301 redirects via the web.config file due to a website redesign recently done. I

@BetL925

Posted in: #301Redirect #Https #Redirects

So this is the scenario, I have already placed some 301 redirects via the web.config file due to a website redesign recently done. I also need to put in place the non-www to www url redirect and on top of that I will suggest to install an ssl certificate which I understand that needs a proper redirect as well.

How should I proceed with the redirects without messing things up or causing infinite loops?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @BetL925

1 Comments

Sorted by latest first Latest Oldest Best

 

@Debbie626

This htaccess snippet should do it for you -- redirects non-WWW to WWW mode, redirects non-HTTPS to HTTPS mode:

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ "https://www.example.com/" [R=301,L]


Sometimes for certain multi-app installs on a hosting account, you may work with "addon domains". These are basically masked subdomains of the host domain. In that case, you can add a couple more lines to really protect those utility routes from being used and forward them to HTTPS WWW as well:

RewriteCond %{HTTP_HOST} ^example.hostdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.hostdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ "https://www.example.com/" [R=301,L]


Now where you put this depends on how specific your existing 301's are. If they use HTTP (or various WWW) explicit routes, then this snippet goes after them. If they are more flexible, or relative, and not based on HTTPS/WWW then the snippet can go before them, or wherever you like.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme