Starting nginx: [emerg]: directive "rewrite" is not terminated by ";"
Code:
Starting nginx: [emerg]: directive "rewrite" is not terminated by ";" in /usr/local/nginx/vhosts/www.site.com.conf:45
Even though the Nginx configuration file contains a rewrite rule which is terminated corectly (with
Code:
last;
), if a rule contains curly brackets {}, then those brackets finish the
location directive in Nginx configuration prematurely, thus making Nginx complaining about line termination.
Example:
Code:
system {
listen 80;
...
location / {
...
rewrite ^/[a-z0-9_-]*-[a-z]{1}([0-9]+)(/(news)+)?(/(digest)+)?(/(short|long)+)?/([a-z0-9_]+)\.xml(\.gz)?$ /gymrss.php?$8=$1&$3&$5&$7&gzip=$9 last;
...
}
}
[hence the curly brackets in [a-z]{1}([0-9]+) ].
To avoid these situations, enclose the first part of the regular expression with double quotes like below:
Code:
rewrite "^/[a-z0-9_-]*-[a-z]{1}([0-9]+)(/(news)+)?(/(digest)+)?(/(short|long)+)?/([a-z0-9_]+)\.xml(\.gz)?$" /gymrss.php?$8=$1&$3&$5&$7&gzip=$9 last;