Blog
Nginx Rewrite Rules
Posted on 6th Jun 2013
Typical Rewrite Rules
Here is an example of how to rewrite www and ssl i n one server block
server {
listen 80;
server_name www.example.com example.com;
return 301 https://example.com$request_uri;
}
This example is for a wordpress sitemap when using Yoast Seo.
rewrite '^/site-map' '/sitemap.xml' permanent;
Pass the PHP scripts to FastCGI server listening @ Unix socket. **Note could also be : location ~ .php$
location / {
try_files $uri $uri/ /index.php?$args;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}