首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在url中生成nginx更改参数

在url中生成nginx更改参数
EN

Stack Overflow用户
提问于 2015-12-25 02:17:35
回答 1查看 269关注 0票数 1

如何更改url中的参数

比如https://example.com/r.php?12345https://example.com/12345

nginx conf文件:

代码语言:javascript
复制
server {
    listen       80;
    server_name  example.com;
    rewrite_log on;
    # note that these lines are originally from the "location /" block
    root   /usr/share/nginx/example.com;
    index index.php index.html index.htm;
    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    } 
}

在conf文件中添加块的位置呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-25 09:22:40

如果URI不映射到本地文件,则try_files的最后一个元素是默认操作。因此,将404错误替换为所需的重写。尝试:

代码语言:javascript
复制
location / {
    try_files $uri $uri/ /r.php?$uri;
}

详情请参见本文件

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34459492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档