我在用nginx。我想重写urls。我的代码:
rewrite ^/([^/]*)_([a-zA-Z0-9]{9}).html$ /watch.php?vid=$2 last;url:14a4e06f8.html示例
但是,当我保存文件,然后重新启动nginx服务器时,我得到了错误:
[emerg] directive "rewrite" is not terminated by ";" in /etc/nginx/conf.d/default.conf:46问:我的重写规则有什么问题?
rewrite ^/([^/]*)_([a-zA-Z0-9]{9}).html$ /watch.php?vid=$2 last;发布于 2015-01-26 19:51:28
花括号{9}很可能会在正则表达式中出现问题。用如下所示的引号包围规则,并尝试它。
rewrite "^/([^/]*)_([a-zA-Z0-9]{9}).html$" /watch.php?vid=$2 last;注意:对于大括号({和} ),因为它们既用于regexes,也用于块控制,为了避免冲突,带花括号的regexes必须用双引号(或单引号)括起来。
更多信息这里
https://stackoverflow.com/questions/28157436
复制相似问题