根据nginx中的$ uri重定向到不同的位置

时间:2017-02-06 10:52:55

标签: nginx

如果存在请求参数,我想重定向到不同的页面:

HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
{
    ConsoleMode savedState(hStdin);
    ::SetConsoleMode(hStdin, savedState.mode & (~ENABLE_ECHO_INPUT));

    std::string sTempPass;
    getline(cin, sTempPass);

   // savedState goes out of scope and runs its destructor to restore state.
   // The destructor runs as part of stack unwinding in case of an exception as well.
}

当前配置:

http://domain.com  --> index.html

http://domain.com/1 --> return 301 https://$host$request_uri;

如何根据uri重定向到位置?

1 个答案:

答案 0 :(得分:0)

尝试以下方法:

...
location = / {
       return 301 http://$host/index.html
}

location ~ ^/1 {
       return 301 https://$host/$1
}
...
相关问题