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 关于下拉菜单选项关联的问题
  • ¥15 如何修改pca中的feature函数
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R