自定义固定链接在Nginx+Apache上不起作用

时间:2012-01-27 作者:user1152342

我有个奇怪的情况。。。将nginx设置为与apache一起使用后,我的permalinks无法工作。

permalinks在不以“.html”结束时工作,但在以“/”结束时工作

ie.:这项工作:justflick。com/new-the-dark-knight-rises-set-photo-2012-01-25。html/汤姆·哈代饰演《黑暗骑士》中的贝恩崛起

但这不是:只是弹一下。com/new-the-dark-knight-rises-set-photo-2012-01-25。html

这是我对这个网站的nginx的困惑。

 server {

  access_log off;

  error_log  /etc/nginx/logs/vhost-error_log warn;
  listen    80;
  server_name  justflick.com www.justflick.com;

  # uncomment location below to make nginx serve static files instead of Apache
  # NOTE this will cause issues with bandwidth accounting as files wont be logged
  location ~* \\.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css)$ {
   root   /home/justflic/public_html;
  }

  location / {
   client_max_body_size    10m;
   client_body_buffer_size 128k;

   proxy_send_timeout   90;
   proxy_read_timeout   90;

   proxy_buffer_size    4k;
   # you can increase proxy_buffers here to suppress "an upstream response
   #  is buffered to a temporary file" warning
   proxy_buffers     16 32k;
   proxy_busy_buffers_size 64k;
   proxy_temp_file_write_size 64k;

   proxy_connect_timeout 30s;


   proxy_pass   http://76.76.22.237:88/;

   proxy_set_header   Host   $host;
   proxy_set_header   X-Real-IP  $remote_addr;
   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
  }
 }

1 个回复
最合适的回答,由SO网友:Pothi Kalimuthu 整理而成

它不起作用,因为Nginx试图将permalink作为静态文件提供。目前,当前配置不允许将HTML文件传递给Apache。请从下面的块中删除“html”部分,以便将永久链接传递给Apache。。。

location ~* .(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css)$ { root /home/justflic/public_html; }
一旦删除html,它应该如下所示。。。

location ~* .(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|js|css)$ { root /home/justflic/public_html; }
希望这有帮助。

结束