2014-04-01 47 views
0

我无法为某些路径和文件类型定义位置块。 我正在使用wordpress并使用生成动态站点地图的插件..它重定向到像sitemapindex.xml这样的路径,它实际上并不存在,并且nginx正在尝试静态地提供它。针对特定路径和某些文件类型的Nginx位置块

我需要能够将此传递到Apache

我要送什么,是http://example.com/blog/ * .XML到Apache。这就是我想,这是不行的..所以例如:

http://example.com/blog/post.xml or http://example.com/blog/sitemapindex.xml 

nginx的配置

server { 

    location ~* ^/blog/*.xml$ { 
     include /etc/nginx/proxy_params; 
     proxy_pass http://127.0.0.1:8080; 
    } 

} 

什么是正确的语法

感谢

回答

1

得逃脱期间

server { 
    location ~* ^/blog/.*\.xml$ { 
     proxy_pass http://127.0.0.1:8080; 
    } 
} 
2

我的图片有类似的问题。在我的应用程序中,图像来自两个不同的位置。

您可以根据网址格式指定不同的来源。你的解决方案会看起来像这样。

location ~* ^/blog/.+\.(xml)$ { 
    root /some/path/; 
    expires 90d; 
} 

location ~* \.(xml|js|jpg|png|css|html|otf|eot|svg|ttf)$ { 
    root /some/other/path/; 
    expires 30d; 
    index index.html; 
} 
相关问题