How To Set WordPress Permalink (rewrite rules) on Nginx
These rules are already in the .htaccess on apache, but if you want to be cutting edge, and get the best performance out of your WordPress blog, you can redo them in Nginx!
Why would you want to do this anyways? Simple. In terms of serving static file requests, Nginx will take up lesser memory, use few resources and is just clearly faster.
The permalink rules need to be placed in your nginx site configuration (the vhost file) under your sites name. You could also put them for all sites if you really want.
Here is a basic example:
That is one correct way, but there are better ways to do this too. Say you know all your static files in the wp- folders are of: jpg, css, php, or js formats, then you should try this:
By doing that you can be more efficient, which if you’re moving to nginx is the whole idea. You’ll notice I didn’t parenthesis encapsulate everything like the prior statement and that’s because the parenthesis captures the item… we don’t need to capture… so I just used the parenthesis to OR the values.
I find the most useful link for Nginx stuff is: http://wiki.nginx.org/
This particular information can be found here: http://wiki.nginx.org/HttpRewriteModule
Keep mind, this is wiki, so to be honest one should always run a live test on your application and see for yourself.
Also - the rewrite rules for much of the Nginx config options are in regexp… so you may need some foundation knowledge first and may have to look up how to modify it. So if you see this, leave me a comment. Let me know what you like to see.
Incoming search terms for the article:
- nginx wordpress permalinks
- wordpress permalinks rules nginx
- nginx wordpress rewrite js scripts
- nginx wordpress permalinks css
- wordpress nginx rewrite
- wordpress nginx rewrite rules
- nginx rewrite wordpress permalink
- nginx rewrite wordpress permalinks
- wordpress permalink rewrite rules
- wordpress permalink nginx