How to avoid landing page redirects?


#1

Hi,

I’ve just updated my blog from a Centminmod installation to a EasyEngine one on my VPS. Everything is working, but I’d like to solve little issues to enhance my web performance.

I’ve made some testing with pages such as Pagespeed Tools and GTmetrix.com and in both cases there’s a problem with my landing page: the error shown is

"Avoid landing page redirects"

And the detailed message reads as follows:

 Avoid landing page redirects for the following chain of redirected URLs.

http://javipas.com/
https://javipas.com/
https://www.javipas.com/

I’ve checked my nginx config files and I’ve tried several changes, but without success.

First, my Wordpress general settings is showing my homepage as

www.javipas.com

and not

javipas.com

But even if I change that, the error stays there.

My /etc/nginx/conf.d/force-ssl-javipas.com-conf contains the following:

server {
        listen 80;
#       listen [::]:80;
        server_name www.javipas.com javipas.com;
#       return 301 https://$host$request_uri;
        return 301 https://javipas.com$request_uri;
}

And my /etc/nginx/sites-available/javipas.com is this:

server {


    server_name javipas.com www.javipas.com;
#   return 301 https://www.javipas.com$request_uri;

    access_log /var/log/nginx/javipas.com.access.log rt_cache_redis;
    error_log /var/log/nginx/javipas.com.error.log;

    root /var/www/javipas.com/htdocs;
    index index.php index.html index.htm;

    include  common/redis-php7.conf;
    include common/wpcommon-php7.conf;
    include common/locations-php7.conf;
    include /var/www/javipas.com/conf/nginx/*.conf;
}

As you can see, I’ve tried to include a permanent redirection but as far as I know this doesn’t work either.

The waterfall analysis on this tests show that this redirections are adding almost 1s in my load time (2.4s total currently). It’s a real pity, and I’d like to know how to avoid those redirects. Detail on the waterfall attached in case it can give more information. Thank you!


#2

Did you verify that you WordPress-Settings are with https:// and with “www.”? Try:

wp option set siteurl https://www.javipas.com
wp option set shome https://www.javipas.com

Hope that helps… Kind Regards, -Ingo


#3

Thanks, but it even makes the problem worse. After changing it to https://javipas.com I had only two GETs instead of three. I guess there’s something in my nginx config files that isn’t right.


#4

Look at your:

/etc/nginx/conf.d/force-ssl-javipas.com-conf

you disbaled this line:

   return 301 https://$host$request_uri;

and introduced this one:

   return 301 https://javipas.com$request_uri;

I think this causes the misbehaviour… Revert this and then check also all nginx-redirects and check also ‘wordpress-redirects’. You can get to your wordpress-options by entering (manual)

https://javipas.com/wp-admin/options.php

into your browser…

Hopy you will get this solved… -Ingo


#5

Thank you again Ingo!

I’ve changed that line and I still get two GETs but I will check it later again to avoid the cache making the tests deceiving in this first moments.

I don’t know how to check eht nginx-redirects and the wordpress-redirects you talk about. I’ve checked the options.php like you mentioned and as far as I know everything is ok there (siteurl is “https://javipas.com” for example).

Javi


#6

I really don’t understand your problem.

If you don’t want the redirect from www to the domain, just don’t link anything with www and there won’t be any redirects.

What am I missing?


#7

There’s nothing with www, at least not in the homepage. If you take a look at the waterfall attached on the first message, the first two GETs are to javipas.com.

That’s the right thing to do, but… why two (or three, in that case in the image) and not just one? That’s what I cannot explain myself.


#8

You are wrong. There are several links pointing to www.javipas.com. Open the page source (CTRL-U, Command-U or whatever) and pay attention to all details.

Or try:

wp search-replace https://www.javipas.com https://javipas.com

But you should better understand what caused your problem first.


#9

Right, thanks. I’ll try that search-replace to fix also those http://www.javipas.com (again, they should all be https://javipas.com) to see if the problem goes away.

I don’t think it will though. I’m pretty sure the problem lies in my nginx config and some particular redirect I have (or haven’t) done.


#10

You don’t have to mess with any Nginx configuration with EE. The defaults are pretty fine.


#11

Fun fact: typing https://javipas.com instead of http://javipas.com in GTmetrix test avoids the second GET, obviously. Everything great over here, that was the problem.


#12