πŸ‘½ 301 redirect coming from page that does not exist!


#1

Hello!

Guys, I have a very strange problem!

I created a post a few days ago and when I went to access the search console I realized that a file page that does not exist is doing a 301 redirect for this post.

There are 2 problems!

1ΒΊ The archive page does not exist. 2ΒΊ I have never done this redirection.

Could someone help me solve this problem.

This is accusing duplicity in the search console.

This is somehow disrupting SEO of this post!


#2

Hello, Can you give us more informations about your configuration ? Plugins ? Redirection from http to https ? etc


#3

This is a problem because I do not use any redirection plugins. And the page that is doing the redirect does not exist. But this is redirecting to an existing post.

Url that does not exist:
mysite.com.br/recipes/

Redirecting to this url:
mysite.com.br/cake-boss

This is the site I checked this redirect for: http://redirectdetective.com/

server {
    server_name  mysite.com.br;
    rewrite ^(.*) https://mysite.com.br$1 permanent;
    
    access_log /var/log/nginx/mysite.com.br.access.log rt_cache;
    error_log /var/log/nginx/mysite.com.br.error.log;

    root /var/www/mysite.com.br/htdocs;

    index index.php index.html index.htm;

    include common/php.conf;
    include common/wpcommon.conf;
    include common/locations.conf;
    include /var/www/mysite.com.br/conf/nginx/*.conf;

}

server {
    server_name  www.mysite.com.br;
    
    access_log /var/log/nginx/mysite.com.br.access.log rt_cache;
    error_log /var/log/nginx/mysite.com.br.error.log;

    root /var/www/mysite.com.br/htdocs;

    index index.php index.html index.htm;

    include common/php.conf;
    include common/wpcommon.conf;
    include common/locations.conf;
    include /var/www/mysite.com.br/conf/nginx/*.conf;

}

#4

Your redirection from non www to www is not correct.

Just use a single server block with

server www.chefclub.com.br chefclub.com.br;

The directive rewrite is not correct with nginx, not the same than apache


#5

I’ve tried using this method, but it does not work here. Here only works with 2 blocks and until today I do not understand why. Using this method the site does not open. It does several redirects.


#6

I will try to change again to use this method. Because on my other server was not working who knows in this new one works. I’ll change and I’ll let you know.

Now it seems to be working well! I left it like this! Is correct?

server {
    server www.mysite.com.br mysite.com.br;
    rewrite ^(.*) https://www.mysite.com.br$1 permanent;
    
    access_log /var/log/nginx/mysite.com.br.access.log rt_cache;
    error_log /var/log/nginx/mysite.com.br.error.log;

    root /var/www/mysite.com.br/htdocs;

    index index.php index.html index.htm;

    include common/php.conf;
    include common/wpcommon.conf;
    include common/locations.conf;
    include /var/www/mysite.com.br/conf/nginx/*.conf;
    
}

#7

@virtubox

When I use a block it error in the test. When I use two it says it is correct.


#8

Your block should look like :

server {
    server_name  www.chefclub.com.br chefclub.com.br;
    
    access_log /var/log/nginx/chefclub.com.br.access.log rt_cache;
    error_log /var/log/nginx/chefclub.com.br.error.log;

    root /var/www/chefclub.com.br/htdocs;

    index index.php index.html index.htm;

    include common/php.conf;
    include common/wpcommon.conf;
    include common/locations.conf;
    include /var/www/chefclub.com.br/conf/nginx/*.conf;

}

Then create a file /etc/nginx/conf.d/yoursitewww.conf :

server {
        server_name example.com;
        return 301 $scheme://www.example.com$request_uri;
}

#9

I created the file as you said it. But note that there is already a force ssl file created in the easy engine installation. Is it to stay that way?


#10

In your force ssl configuration file, the redirection is set to https://www.yourdomain.tld ?


#11

It is like this

server {
	listen 80;
	server_name www.mysite.com.br mysite.com.br;
	return 301 https://www.mysite.com.br$request_uri;
}

#12

Try this configuration :

server {
listen 80;
        server_chefclub.com.br;
        return 301 https://www.example.com$request_uri;
}
server {
listen 80;
server_name www.chefclub.com.br;
return 301 https://www.chefclub.com.br$request_uri;
}

#13

Within force SSL?


#14

Yes, just remove the other configuration file


#15

I put it like this!

server {
listen 80;
        server_mysite.com.br;
        return 301 https://www.mysite.com.br$request_uri;
}
server {
listen 80;
       server_name www.mysite.com.br;
       return 301 https://www.mysite.com.br$request_uri;
}

But the error in the test.

nginx: [emerg] unknown directive β€œserver_mysite.com.br” in /etc/nginx/conf.d/force-ssl-mysite.com.br.conf:3 nginx: configuration file /etc/nginx/nginx.conf test failed


#16

@virtubox

In this way it seems to work perfectly.

server {
listen 80;
       server_name www.mysite.com.br mysite.com.br;
       return 301 https://www.mysite.com.br$request_uri;
}

~# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful


#17

@virtubox

I noticed that now this urls (https://mysite.com.br/) is not redirecting to www


#18

Have you applied the configuration with service nginx reload ?


#19

yes


#20

@virtubox

Showing this in the redirection test. For this url