Skip to content

Instantly share code, notes, and snippets.

@tsipiniuk
Forked from chris/nginx_pagination_fix.conf
Created September 8, 2018 10:38
Show Gist options
  • Save tsipiniuk/04c36b0de16e06dd3c97e6f67e967817 to your computer and use it in GitHub Desktop.
Save tsipiniuk/04c36b0de16e06dd3c97e6f67e967817 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