How to fix WordPress permalinks in Nginx

WordPress is blazing fast in Nginx. The only problem is the permalinks structure.


Unlink Apache, with mod_rewrite builtin, Nginx has no module like that. Because WordPress cant detect the module, it will fallback to PATHINFO directive, forcing an “index.php” on your links. You have to add the “rules” manually if you want to remove that and use the custom structure successfully.


Log on your root terminal, perform (assuming you have

sudo pico /etc/nginx/sites-enabled/

Add / Edit the following line:

server {
rewrite ^(.*) //$1 permanent;

server {
root /var/www/;
include /etc/nginx/fastcgi_php;
location / {
index index.php;
if (!-e $request_filename) {
# rewrite ^(.*)$ /index.php last;
rewrite ^(.+)$ /index.php?q=$1 last;

You can of course use FTP if you wish. But you still need root access to the terminal to make the changes take effect:

nginx -s reload

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.