문제

I had a rewrite rule on Apache for /year/month/date links in a form that specifically defined 4 digits, then 2 digits, then 2 digits, that looked like this:

^([0-9]{4})/([0-9]{2})/([0-9]{2})/$

On nginx this regex causes an error that says the whole line is not terminated by a ; sign, until i remove the {} brackets and leave the regex like this:

^/([0-9]+)/([0-9]+)/([0-9]+)/$

Is this limitation intentional on nginx's part or some mistake on my part?

The whole line from Apache:

RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/$ index.php?page=date&year=$1&month=$2&day=$3

The whole (working) line from nginx:

rewrite ^/([0-9]+)/([0-9]+)/([0-9]+)/$ /index.php?page=date&year=$1&month=$2&day=$3;
도움이 되었습니까?

해결책

If a regular expression includes the “}” or “;” characters, the whole expressions should be enclosed in single or double quotes.

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top