doudou5421 2015-11-14 22:11
浏览 61

Nginx重写为php补丁

I need to rewrite those url:

rewrite /shop.php?category=catergory1 http://example.com/c123 permanent;
rewrite /shop.php?category=category2 http://example.com/c234 permanent;

but get "No input file specified" instead of redirecting.

how i should properly write those ?

p.s. i have about one hundred of links like

^/shop.php?category=camp&subcategory=&showitem=26
^/shop.php?category=stove&subcategory=&showitem=14

and need redirect all of them into 2 different urls - all category=camp to /url1 and all category=stove to /url2 i dont need all of the parameters other than first one in base url.

p.p.s i should do about 2 thousand permanent redirects for my project. could the processing of this redirects be reduce nginx working speed ?

  • 写回答

1条回答 默认 最新

  • dongxiangchan0743 2015-11-14 23:25
    关注

    Regarding your p.s. this configuration should work for you. Matching the query directly in the rewrite won't work.

    location /shop.php {
        if ($args ~* "/?category=camp") {
            rewrite ^ http://example.com/url1? permanent;
        }
        if ($args ~* "/?category=stove") {
            rewrite ^ http://example.com/url2? permanent;
        }
    }
    

    The question mark after "url1" is used to remove the query from the old url.

    I'm not quite sure about the performance of that many redirects, however the answers to this question contain some information about that fact.

    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM