nginx rewrite rule:
rewrite ^/([a-z]+)$ /?type=$1 last;
rewrite ^/([a-z]+)/page/([0-9]+)$ /?type=$1&page=$2 last;
can I merge these two rules into one?
Haven't tested it but something like this might work..
^/([a-z]+)/?(page/([0-9]+)|)/?
Edit : here's the full block:
location ~ /(blog)/?(page/([0-9]+)|)/? {
default_type 'text/plain';
echo "$1";
echo "$2";
echo "$3";
}
Going to /blog produces
blog
Going to /blog/page/3 produces
blog
page/3
3
$3 will have the page number if it's been specified otherwise it will be empty.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.