Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save skive/d273714c77b3742e00bb to your computer and use it in GitHub Desktop.
Save skive/d273714c77b3742e00bb to your computer and use it in GitHub Desktop.
Nginx: Wordpress Virtual Host
server{
listen [port];
server_name [url] [www.url];
access_log [access_log_location];
error_log [error_log];
root [where_to_serve_from];
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
location ~* \.(jpg|jpeg|gif|css|png|js|ico|xml)(\?[0-9]+)?$ {
access_log off;
expires max;
fastcgi_hide_header Set-Cookie;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php?$uri&$args;
index index.php index.html;
port_in_redirect off;
}
location ~* \.php$ {
include /etc/nginx/fastcgi_params;
include /etc/nginx/fastcgi_config;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_pass [sock-or-address];
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment