You are reading

WordPress Permalinks in Nginx

Posted: January 22, 2010 | By: TJ | In Technology | No comments yet

Setting up permalinks in WordPress is very easy in Apache. A few lines of mod_rewrite in the .htaccess and you’ve got pretty URLs. If you plan on using Nginx, the process is a bit different however the idea is the same. Essentially, you’ll want to add rewrite request directive in the virtual host configuration. This may vary depending on how you set up Nginx but this is the code you’ll need:

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break; }

You can place the rewrite directive in the location section. Here is what I am using with this blog:

location / {
root   /var/www/constantshift.com/public/;
index  index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break; }
}

Leave your comment



Copyright © 2010. All rights reserved.

This blog is powered by WordPress and proudly hosted by (mt) Media Temple.