• Resolved Alejandro J. Sanchez P.

    (@elpanda13gmailcom)


    Hi,

    i have an issue with one site i’m working on. i helped fix a few mistakes another developer did on a wordpress install and the site is working fine now and is way faster but there’s a weird thing going on with redirects that makes the site load slower.

    The site is: https://bit.ly/1pCZclr

    if you open that link you’ll see it takes over 4s to load, this is because the link provided is the NON-www and NON-HTTPS version.
    if you run it on pingdom you’ll see that it has a lot of redirects.

    Let’s imagine i’m talking about site.com. the “default” version should be https://www.site.com

    so if you try to access the site using only “site.com” it will do all this redirects: https://prntscr.com/akb1x1

    the .htaccess only has a few lines of code added besides the standard one and looks like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    #https
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    #end https
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    #RewriteCond %{HTTP_HOST} ^site.com$
    #RewriteRule ^/?$ "http\:\/\/www\.site\.com\/" [R=301,L]

    i only added the HTTPS line, the rest is untouched.

    before the SSL the standard version was the https://www.site.com address.

    Hope you can help me out.

Viewing 2 replies - 1 through 2 (of 2 total)
  • @alejandro,

    Simplify your rewrites. Here is a good solution:

    #First rewrite any request to the wrong domain to use the correct one (here www.)
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    #Now, rewrite to HTTPS:
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    Source: https://stackoverflow.com/a/19509934

    In my opinion, Nginx makes this process a bit easier.

    As far as slow loading time, its probably your server, not the rewrites.

    Thread Starter Alejandro J. Sanchez P.

    (@elpanda13gmailcom)

    Wow, for some reason i never got a notification mail for this thread. i just did what you recommended and it has notably decreased the redirection time.

    The site is not slow per se, it loads in under 1.5s (i slowed it down from 7s to just that with a lot of customization) and like 500ms from that time is due to the server. the site runs on a hostingdns’ shared plan so i suppose that’s why.

    Thanks for everything!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘3 redirects after installing SSL certificate’ is closed to new replies.