Wordpress Ngnix Rewrite Rules

From Brian Nelson Ramblings
Jump to: navigation, search

Wordpress + Nginx Rewrite Rules

After installing Nginx you noticed that it does not play nice with the default .htaccess rewrite rules.

You will want to add the following to your vhost file for nginx.

To get the default wordpress to function correctly without custom rewrite rules, add the following to your vhost file.

vim /path/to/your/vhost.conf 

Add the following

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

Now check and make sure all syntax is correct

nginx -t

Then restart nginx if all is correct

/etc/init.d/nginx restart