Fix 301 Redirect additional 3 second delay?

Discussion in 'Site & Server Administration' started by avattz, May 27, 2014.

  1. #1
    I have a WordPress website which redirects the non-www to the www version, but when redirecting there is a delay of 6 seconds before downloading any content. When going directly to the www version the website starts downloading at 2.8 seconds and finishes completely in under 5 seconds while if i go to the non-www version it takes almost 8 seconds to complete the webpage. This is done by clearing cache after every attempt. I can understand the 2.8 seconds is for finding the server and the server generating PHP, but whats causing the additional 3 seconds when redirecting?

    I used to use a mod_rewrite redirect but later I found out that Wordpress handles redirection on its own so I'm wondering if Wordpress is causing that. If I use mod_rewrite then Wordpress just causes an infinite loop when requesting the website.
     
    avattz, May 27, 2014 IP
  2. RobinInTexas

    RobinInTexas Active Member

    Messages:
    217
    Likes Received:
    14
    Best Answers:
    2
    Trophy Points:
    65
    #2
    Use htaccess redirect. It's almost instant. Wordpress has to connect to the database and read the file and send the redirect. Lots of work for the server. With htaccess, wordpress never even sees the incorrect request, Apache does it on its own. Much more efficient.
     
    RobinInTexas, May 27, 2014 IP
  3. avattz

    avattz Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Thanks for the info, would you happen to know how to disable the WordPress redirect, I get an infinite 301 loop if I also add a mod_rewrite redirect with the WordPress redirect.
     
    avattz, May 27, 2014 IP
  4. ironcladservers

    ironcladservers Well-Known Member

    Messages:
    389
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    115
    #4
    Disable any redirection plugin you have in your WP, and only use the .htaccess redirect. If it's still redirecting in some way, then you need to adjust the WP database to have the correct URL applied as its default URL, whether that be non-www or www. Make sure the .htaccess redirects to the one you want (non-www or www), and make sure the WP database has this too in its config.
     
    ironcladservers, Jun 11, 2014 IP