我在我的 nginx.conf 中重写了:
server {
server_name example.com;
rewrite ^/(.*) http://www.example.com/$1 permanent;
}
但返回此错误:未知指令“重写”。
PS:我已经用 passenger 安装了 nginx。
你能帮帮我吗?
最佳答案
检查 nginx -V 的输出。如果你看到选项 --without-http_rewrite_module,那么你可能在构建 nginx 时没有安装 pcre 开发包,所以它禁用了重写模块。如果是这种情况,您将需要安装 pcre 开发包(如何执行此操作取决于您的发行版)并重建 nginx。
关于linux - Nginx 错误 : unknown directive rewrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7850163/