9 responses to “WordPress NGINX Rewrite Rules”

  1. Dimitris Oupas

    Thanks!

    Finally rules that work :)

  2. Brad Proctor

    For www to non-www, you should set up a second virtual server

    server {
       server_name http://www.example.com;
       rewrite ^ http://example.com$request_uri? permanent;
    }
    
    server {
       server_name example.com;
       ...
    }
    

    Also, instead of the

    if (!-e $request_filename)

    segment, you should use try_files

    location / {
       try_files $uri $uri/ /index.php
    }
    
  3. mattonomics

    Out of curiosity, are you familiar with an nginx/WordPress problem where rewritten pages (e.g. site.com/%postname%/) cannot properly proces $_GET vars? I’m running into this issue.

    For the url site.com/page/?foo=bar&blue=smurf, print_r($_GET) is outputting q=>page and nothing else!

  4. Ovidiu

    just wondering why on my test site, in the permalinks settings wordpress seems to like to place an index.php in-between? it all works fine without…

    http://www.diigo.com/item/image/1eygw/ois4

  5. Fadlee

    @Ovidiu, you can use this plugin fix that trouble:

    http://wordpress.org/extend/plugins/nginx-compatibility/

  6. Ovidiu

    @Fadlee: thanks, worked perfectly :-)

  7. Dhruv

    Hey Dimas,

    Any tips on combining WordPress AND CodeIgniter? I am running a WP install in the root folder (with this config, a modified version of the Roots WP Theme config: here). However, I’m also trying to migrate a CI app into a /subdirectory/ on my site. I’ve managed to get the default controller to show (without the index.php), but any other controllers or methods simply break and show my WP 404 page! HIstorically, the CI app used to run on an Apache server with pretty URL’s just fine.

    Any help is appreciated :D

  8. Dhruv

    I managed to sort it out after tweaking a few settings. :) My config is available here.

Leave a Reply