Not signed in (Sign In)
    • CommentAuthortransphorm
    • CommentTimeJul 23rd 2007
     permalink
    Just wanted to help out my fellow slicers who are running nginx+fcgi+php+wordpress. I wanted to get some pretty permalinks using /%category%/%postname%/.
    Here's the config snippet:

    location / {
    root /var/www/directory; <--- change this to your directory
    index index.php;
    rewrite ^/(.+)/(.+)/$ /?category=$1&name=$2;
    if ($request_uri != '/wp-admin/') {
    rewrite ^/(.+)/$ /?pagename=$1;
    }
    }

    I don't have any use for archives so I didn't put them in my conf file. This is something just to get you started. The first rewrite takes whatever is in between / and puts them into a query string format. The second rewrite is for pages with the exception of wp-admin so you can still login to your control panel. I haven't tested downloading files but everything else including the admin section seems to work.

    Here's a great reference I stumbled across if you're going to make your own query strings:
    http://codex.wordpress.org/User:Cameron/Query_Variables
    • CommentAuthortransphorm
    • CommentTimeJul 23rd 2007
     permalink
    Shucks I just realized that I have to add another regex for detecting category.
    • CommentAuthortransphorm
    • CommentTimeJul 23rd 2007
     permalink
    Okay I finally got it. Sorry for the rough first drafts here it is:

    if ($http_user_agent !~ FeedBurner) {
    rewrite ^/feed/$ http://feeds.feedburner.com/yourFeed permanent; <----change this
    }
    if ($http_user_agent !~ FeedBurner) {
    rewrite ^/comments/feed/$ http://feeds.feedburner.com/yourFeedComments permanent; <--- change this
    }
    if (!-e $request_filename) {
    rewrite ^/([^.]*[^/])$ http://yoursite.com/$1/ last; <---change this
    rewrite ^/wp-admin/$ /wp-admin/ break;
    rewrite ^/category/(.+)/$ /?category$1 break;
    rewrite ^/(.+)/(.+)/$ /?category=$1&name=$2;
    rewrite ^/(.+)/$ /?pagename=$1;
    }

    Okay the first two if only affect feed urls. The second set check for wp-admin and category and also if trailing slash is not set (thanks fucoder.com).
    •  
      CommentAuthorscotty
    • CommentTimeJul 23rd 2007
     permalink

    It is actually much simpler...

    if ($http_user_agent !~ FeedBurner) {
        rewrite ^/comment/feed/ http://feeds.feedburner.com/your-comment-feed last;
        rewrite ^/feed/ http://feeds.feedburner.com/your-feed last;
    }
    
    if (!-e $request_filename) {
        rewrite ^.*$ /index.php last;
    }
    

    Just pass everything to /index.php, as WordPress handles mapping the URI to posts internally.

    Thankful People: transphorm
    • CommentAuthortransphorm
    • CommentTimeJul 23rd 2007
     permalink
    Now you tell me....lol

    Thanks scotty.
    • CommentAuthortransphorm
    • CommentTimeJul 23rd 2007
     permalink
    Actually it's a little bit more this:


    rewrite ^/comment/feed/ http://feeds.feedburner.com/your-comment-feed last;
    rewrite ^/feed/ http://feeds.feedburner.com/your-feed last;


    should be this


    rewrite ^/comment/feed/?$ http://feeds.feedburner.com/your-comment-feed last;
    rewrite ^/feed/?$ http://feeds.feedburner.com/your-feed last;


    So that /feed without the trailing slash will still point to feedburner and not point to your own feed. Thanks again.
    • CommentAuthorjamesdkirk
    • CommentTimeJun 16th 2009
     permalink

    I know it’s been a while, but how would I use this concept to enable configuration level redirecting to feedburner for any number of domains being served through the virtual host container?

    TIA!