• Resolved utnalove

    (@utnalove)


    Hello,

    the AMP links give a 404 error.
    Please try to surf posts, homepage, etc: https://www.anahatatantra.com/staging/learn

    As you can see if you add /amp/ – you get a 404 errors or it gets redirected to the homepage.

    Here is the ngixn config:
    https://pastebin.com/2FEtTgzT

    I tried to add (of course with the right path)

    location /staging{
            root /var/www/html/staging/;
    
            location ~ \.php$ {
                    include snippets/fastcgi-php.conf;
                    fastcgi_pass unix:/run/php/php7.1-fpm.sock;
            }
    
    }

    but it didn’t help.

    Can you please help?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Rene Hermenau

    (@renehermi)

    Hi,

    the link is directing to the production site. Did you already remove the staging site?

    Thread Starter utnalove

    (@utnalove)

    Hi, no I didn’t remove it, because I was waiting for your reply.
    Yes. For some strange reason it’s redirecting to the production site.

    However if I go to https://www.anahatatantra.com/staging/ I see the staging site.

    But when I try to click on pages or posts that have /staging/ in the URL, they redirect to the production site.

    I think this is an additional problem that happened while waiting for your reply…

    Plugin Author Rene Hermenau

    (@renehermi)

    Your nginx.conf looks unusual. You have two server blocks listening to port 443. The first block is redirecting all links. This could be part of the reason: http://take.ms/Bihxq

    I do not know such a variant, only using one server block per port.

    Anyways, the correct block for your php version config should be:

    location /staging{
            root /var/www/html/staging/;
    
            location ~ \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SERVER_NAME $host;
                    include fastcgi_params;
            }
    
    }

    You do not use php 7.1.

    Before you use that configuration use nginx -t command from bash to check the nginx.conf for syntax errors.

    • This reply was modified 5 years, 5 months ago by Rene Hermenau.
    Thread Starter utnalove

    (@utnalove)

    Hi, the two servers blocks are correct because the first one redirects, using https, all the requests non-www to www.
    This is the same job that wordpress does, however nginx is much faster than PHP and it’s better if done in the server not via PHP.

    The problem comes later. Now, I added the code you provided above, and as you can see I get 404 errors:

    2018/10/16 06:00:06 [error] 29253#0: *83130 "/var/www/html/staging/staging/index.php" is not found (2: No such file or directory), client: 89.65.64.196, server: www.anahatatantra.com, request: "GET /staging/ HTTP/1.1", host: "www.anahatatantra.com"

    /staging/staging/ is appearing this way… like double

    Plugin Author Rene Hermenau

    (@renehermi)

    Is that path correct for your website?

    root /var/www/html/staging/;

    Can you show me the entire nginx.conf for your site including that modification?

    Please send it to support [at] wp-staging.com and do not post it to pastebin due to security purposes. You should also delete your old file there.

    • This reply was modified 5 years, 5 months ago by Rene Hermenau.
    Thread Starter utnalove

    (@utnalove)

    The production site is at
    /var/www/anahatatantra.com

    the staging files are at
    /var/www/html/staging/

    So I suppose I have to change
    /var/www/html/staging/
    to
    /var/www/anahatatantra.com/staging/

    I just changed it and the error is still 404:
    2018/10/16 06:29:01 [error] 29512#0: *83946 "/var/www/anahatatantra.com/staging/staging/index.php" is not found (2: No such file or directory), client: 89.65.64.196, server: www.anahatatantra.com, request: "GET /staging/ HTTP/1.1", host: "www.anahatatantra.com"

    I updated the nginx config:
    the ngixn config:
    https://pastebin.com/2FEtTgzT

    Plugin Author Rene Hermenau

    (@renehermi)

    I think I had something missing in my answer. Please try that code. Is it working?

    location /staging {
            try_files $uri $uri/ /staging/index.php?q=$request_uri;
     
            location ~ \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SERVER_NAME $host;
                    include fastcgi_params;
            }
    } 
    Thread Starter utnalove

    (@utnalove)

    Yeah, thank you. This is working fine. You can test it.

    Now the problem seem to be that when the user clicks the flag to change the language, while in AMP, the user gets redirected to the non-amp page of the other language

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Not working with AMP for WP’ is closed to new replies.