This forum is dedicated to Apache, Nginx, Lighttpd, Squid and other HTTP transport protocol related software

Advertisement


DNS query tools & Network tools (Ping & Traceroute)

Starting nginx: [emerg]: directive "rewrite" is not terminated by ";"

Postby debuser » Tue Feb 23, 2010 1:05 pm

Code: Select all
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: Select all
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: Select all
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: Select all
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;
debuser
 
Posts: 70
Joined: Thu Aug 06, 2009 9:48 am


Advertisement


Return to Apache, Nginx, Lighttpd and other web server software

Similar topics


Who is online

Users browsing this forum: No registered users and 0 guests

cron