Support » Fixing WordPress » WordPress Permalinks on NGINX

  • simonnin

    (@simonnin)


    I am running 3 WordPress sites on my Webuzo VPS on a LEMP environment.
    I have added permalinks from the Admin Portion > Settings >> Permalinks, but my links result in a 404 page not found error.

    I toggled to Apache as the default webserver on the same VPS and the permalinks work fine, but I want to use NGINX as the default webserver for my sites.

    How do I fix this ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Dave Naylor

    (@wpranger)

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    WordPress added support for nginx and permalinks in 3.7, so some of that article is out of date.

    However, WordPress won’t write an nginx config file for you, because it doesn’t know your setup or where to put the config files. Unlike Apache, an .htaccess file in the directory is not quite a standard for nginx.

    An extensive config file is here:
    http://codex.wordpress.org/Nginx#General_WordPress_rules

    However most of that is really unnecessary for a basic nginx configuration. The rule could be as simple as this in the relevant server block:

    location / {
            try_files $uri $uri/ /index.php?q=$request_uri;
    }

    Everything other than that is more or less prettification or rewrites for personal tastes (blocking annoyances, things like that).

    Dreamhost, for example, recommends something like this:
    http://wiki.dreamhost.com/Nginx#Permalinks

    if (!-e $request_filename) {
      rewrite ^.*$ /index.php last;
    }

    Which works but might be a tad slower.

    The rules get more complex for things like multisite and such.

    Where should I put that line of code? (this:

    location / {
            try_files $uri $uri/ /index.php?q=$request_uri;
    }

    )

    @thomas040ehv

    In your /etc/nginx/sites-available/*configfile*

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress Permalinks on NGINX’ is closed to new replies.