Simple Nginx Rewrite RulesJun 162014
Nginx is fast becoming the choice http server. In short it is faster and more secure than many of the other choices such as Apache. Creating rewrite rules for Nginx is an important part of any content strategy and it is not always as straight forward as Apache. This brief tutorial will demonstrate the basic setup for a rewrite rule.
You will need to create a folder and a file for your rewrite rules. Go to your root nginx folder usualy in /etc/nginx/.
mkdir rewrite rules
cd rewrite rules
Now that you are in the file you will need to write a rule. Let us pretend you want to create a redirect from /thisisit to http://othersite.com .
rewrite ^/thisisit(.*)$ http://othersite.com$1 permanent;
In addition you will need to include your rewrite file in you configuration file. Here is the code you will need to add;
Next you will need to test your configuration with nginx -t and if it passes reload nginx -s reload . You rewrite rule should now be good to go if you need more complex rules you will need to know a little about regex.