社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  NGINX

位置匹配后nginx重写

Simon55 • 7 年前 • 997 次点击  

我对nginx很陌生,只是想做一些我认为应该很简单的事情。如果我这样做了:

卷曲 http://localhost:8008/12345678

我希望返回index.html页面。但我却找不到404。/usr/share/nginx/html/12345678没有这样的文件

如果我卷曲 http://localhost:8008/ 我希望请求被传送到 http://someotherplace/ 但是我找到了302,就这样。

对基本问题表示歉意,但希望能得到一些建议!

这是代码:

server {
    listen 8008;
    server_name default_server;

    location / {
       rewrite ^/$ http://someotherplace/ redirect;
    }

    location ~ "^/[\d]{8}" {
       rewrite ^/$ /index.html;
       root /usr/share/nginx/html;
    }
}
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40088
文章 [ 2 ]  |  最新文章 7 年前