【问题标题】:How to redirect urls on a NGINX environment?如何在 NGINX 环境中重定向 url?
【发布时间】:2012-05-20 21:07:11
【问题描述】:

我正在尝试从以下位置重定向: http://domain.com/public/photos/large/test.jpg 至: http://domain.com/images/public/photos/large/test.jpg 在 NGINX 环境中。

我的 vhost 文件配置如下。 我的问题是这样的语法不起作用:

server {
       ........
       rewrite ^(public/photos/(.*)) http://domain.com/images/$1 last;
       location / {
            location ~.*\.(3gp|jpg|jpeg|gif)$ {
                expires 7d;
                try_files $uri @backend;
            } 
       }
       ..........
}

rewriterule 语法在 .htaccess 环境中进行了测试,现在已经运行了 2 年多。在 nginx 上它不再存在了。

有什么想法吗? 10 倍

【问题讨论】:

    标签: .htaccess url-rewriting nginx


    【解决方案1】:

    试试这个:

    rewrite ^/public/photos/(.*)$ http://domain.com/images/public/photos/$1 last;
    

    【讨论】:

    • 感谢您的回复。还没有运气。我修改了一下,然后重启了NGINX,和http服务。
    猜你喜欢
    • 2012-05-04
    • 2013-08-04
    • 2013-06-11
    • 2013-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    相关资源
    最近更新 更多