Redirect 在nginx中,URL重定向到非http URL

Redirect 在nginx中,URL重定向到非http URL,redirect,nginx,url-redirection,http-redirect,Redirect,Nginx,Url Redirection,Http Redirect,我使用nginx作为反向代理。如何在nginx的服务器块中设置URL重定向,以便重定向到的URL是非http URL 例如,我有一个url类型: http://example.com/user_uuid/a0d525aa-d755-11e5-b5d2-0a1d41d68578/14084561234/ 我想从上面重定向到非http url: sms:14084561234?正文:我的照片位于http://example.com/photos/a0d525aa-d755-11e5-b5d2-0a1

我使用nginx作为反向代理。如何在nginx的服务器块中设置URL重定向,以便重定向到的URL是非http URL

例如,我有一个url类型:

http://example.com/user_uuid/a0d525aa-d755-11e5-b5d2-0a1d41d68578/14084561234/

我想从上面重定向到非http url:

sms:14084561234?正文:我的照片位于http://example.com/photos/a0d525aa-d755-11e5-b5d2-0a1d41d68578/

当此非http url点击浏览器时,设备的本机SMS应用程序将打开,在SMS中预先填入电话号码1-408-456-1234,并在正文中填入非http url中出现在正文后的文本。当然,这仅适用于移动设备

这是可能的吗?如果是,你能给我举个例子吗?请注意,在第一个URL中,
uuid
和编号是基于一些先前的输入动态生成的



我已经知道如何在web应用程序的代码中实现重定向,但这不是问题所在。

以下配置有效:

server {
    listen 99;
    server_name test.so;

    location /user_uuid {
        rewrite /user_uuid/(.+)/([^/]+) "sms:$2?body:my photo is located at http://example.com/$1/" redirect;
    }

}
样本输出

curl -I -H "Host: test.so" http://localhost:99/user_uuid/uuid/phone/

HTTP/1.1 302 Moved Temporarily
Server: nginx/1.7.11
Date: Sat, 20 Feb 2016 00:45:22 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: sms:phone?body:my photo is located at http://example.com/uuid/

谢谢你的回复。我会测试一下,然后再给你回复。