• Resolved neo4evr

    (@neo4evr)


    Hello,

    I am facing multiple redirects when typing https://www and it is using double redirects to reach to https://non-www. First it goes to https://www and then goes to the https://non-www version. I want to avoid the extra redirect.

    So basically what I want to achieve is this:

    https://www.domain.com - > https://domain.com without any extra redirect
    https://domain.com - > https://domain.com
    https://www.domain.com - > https://domain.com

    All the URL’s should redirect directly to https://domain.com

    I have added the following code to .htaccess file, but it doesn’t seem to work:

    #redirect all www requests to non-www.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    </IfModule>
    
    #redirect all non https requests to SSL
    # BEGIN rlrssslReallySimpleSSL rsssl_version[2.5.11]
    <IfModule mod_rewrite.c> RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%/$1 [R=301,L]
    </IfModule

    Can you please help me to achieve what I want? The above code does not seem to work. I am still seeing the extra redirect and it is increasing the TTFB.

    Many thanks!

    • This topic was modified 3 years, 5 months ago by neo4evr.
    • This topic was modified 3 years, 5 months ago by neo4evr.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    The redirect you have is actually the best practice secure redirect for redirection from https to https. As the redirect is with a SEO friendly 301 redirect, it won’t hurt SEO. If you don’t have this, you allow for “man in the middle” attacks, unless you have HSTS preload enabled.

    For more information on this subject, see this article:
    https://really-simple-ssl.com/knowledge-base/avoid-landing-page-redirects/

    Which also includes instructions how to bypass it, if you want to use the non-best practice redirect.

    Thread Starter neo4evr

    (@neo4evr)

    Hi. Thanks for your reply ??
    The problem with this extra redirect is that it is increasing my website’s TTFB by a huge extent. Each redirect request is taking 300-1000ms time (it is varying, I use a shared server plan on Hostinger).
    I was thinking that if I reduce these redirects, then it can decrease the TTFB?

    I have followed the article and tried to implement the code in .htaccess, but it is not working. I am still getting the extra redirect.

    https://www.sycyoga.com
    301 Moved Permanently
    https://www.sycyoga.com/ - > Extra redirect, I want to remove this
    301 Moved Permanently
    https://sycyoga.com/
    200 OK
    Plugin Support Leon Wimmenhoeve

    (@leonwimmenhoeve)

    Hi @neo4evr,

    As my colleague mentioned, the multiple redirects are actually intentional. You should always redirect to https first, before redirecting to the non-www version of the site. The linked article describes why you shouldn’t avoid the extra redirect.

    Kind regards,
    Leon

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to avoid multiple redirects?’ is closed to new replies.