Skip to content

Instantly share code, notes, and snippets.

@chris
Created May 5, 2009 02:16
Show Gist options
  • Save chris/106796 to your computer and use it in GitHub Desktop.
Save chris/106796 to your computer and use it in GitHub Desktop.
Nginx rewrite rule to change ?page pagination URL's to /p style
if ($request_uri ~* ^(.+)\?page=1$) {
set $dom_prefix $1;
set $args '';
rewrite ^(.*)$ $scheme://$host$dom_prefix permanent;
break;
}
if ($request_uri ~* ^(.+)\?page=(\d+)$) {
set $dom_prefix $1;
set $page $2;
set $args '';
rewrite ^(.*)$ $scheme://$host$dom_prefix/p$page permanent;
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment