linux - Nginx 错误 : unknown directive rewrite

标签 linux mod-rewrite nginx passenger

我在我的 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/

相关文章:

linux - 如何在 Ubuntu 18.04 WSL 中安装最新版本的 NuGet.exe CLI?

linux - 如何根据公共(public)列合并文件?

c - c程序中的多个fork()

apache - .htaccess 在文件不存在时重定向

nginx - 先通过nginx慢速连接

php - Magento 阻止 Varnish 缓存页面

linux - Perl 的 %ENV 在一行中不起作用

apache - .htaccess 使用 END 标志将多个子域重定向到文件夹

apache - 带有子域和 url 模式的 mod_rewrite

spring - Nginx HTTPS-> HTTP 使用 Spring 获取 403 "SSL required"错误