Question

Lemp Permalink not wrking on wordpress

Posted October 11, 2020 81 views
WordPress

Hello guys,
I deployed a Lempfrom Marketplace and upload my wordpress

For wordpress I have that line on my nginx

location /faq/ {
try_files $uri $uri/ /index.php?$args;
index index.php;
}

But the permlink is not working, do you guys have any idea what could it be?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi @sandro2567,

Can you post your whole Nginx configuration file? The bit you have provided looks alright but there might be something else that’s missing from the whole config.

Otherwise, what’s the error you see when you try to load the /faq/ page?

Regards,
KFSys

  • sure, here it is:

    server {
    
        root /var/www/perolarangel;
        index index.php index.html index.htm;
    
        # Make site accessible from http://localhost/
        server_name perolarangel.com www.perolarangel.com; # managed by Certbot
    
    
        location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            # try_files $uri $uri/ =404;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
        }
    
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root /usr/share/nginx/html;
        }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }
    
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #   deny all;
        #}
    
    
        listen [::]:443 ssl ipv6only=on; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/perolarangel.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/perolarangel.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    
       location /faq/ {
        try_files $uri $uri/ /index.php?$args;
        index index.php;
        }
    }
    
    server {
        if ($host = www.perolarangel.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
    
        if ($host = perolarangel.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
    
        listen 80 ;
        listen [::]:80  ;
        server_name perolarangel.com www.perolarangel.com;
        return 404; # managed by Certbot
    }
    
    edited by MattIPv4
    • Hi @sandro2567,

      It does look alright but havin said that, can you edit the location block a bit to see if it would work for your like so

        location ^~ /faq {
          try_files $uri $uri/ /index.php?$args;
          index index.php;
        }
      

      The ^~ modifier causes the prefix location to take precedence over regular expression locations at the same level.

Hi @sandro2567,

Hmm, that’s really weird!

Having said that, It shouldn’t be related to your PHP extensions.

Okay so, I saw a couple of things to change in your Nginx configuration file. First, you don’t server anything in your location / block. Can you try and configure it like so :

        location / {
                try_files $uri $uri/ =404;
        }


        location /faq {
                index index.php index.html index.htm;
                try_files $uri $uri/ /faq/index.php?q=$uri&$args;
        }

Notice I’ve updated the location /faq server block a bit. It should help out and work as expected.

  • nop, still nothing, I think there must be something else that is not nginx.
    I went to this address:
    https://wordpress.org/support/article/nginx/

    and now it is working with these configuratins:

    location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
    
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
    
        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }
    
        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                #fastcgi_pass php;
        }
    
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
    
Submit an Answer