nginx 重写配置

在iis上的重写配置是这样的

图片描述

我在nginx上的配置是这样的,但是除了index.php和/目录能出来,其他都是file not found 肯定是我配置的问题

location ~^view-(\d+)\.html {
                root           /home/nbjtjc/www.nbjtjc.com;
                rewrite       ^view-(\d+)\.html /index.php?m=v&id=$1 last;
                rewrite       ~^([^?]+).html  "/index.php?m=c&a=$1" last;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }    

        location /view-1022.html {
          root  /home/nbjtjc/www.nbjtjc.com;
          rewrite       ^view-(\d+)\.html /index.php?m=v&id=1022 last;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include        fastcgi_params;
          
        }
        location / {
          root  /home/nbjtjc/www.nbjtjc.com;
          rewrite       ^view-(\d+)\.html /index.php?m=v&id=$1 last;
          rewrite       ~^([^?]+).html  /index.php?m=c&a=$1 last;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include        fastcgi_params;
          
        }
            
       
        
         location ~* \.php$ {
            root           /home/nbjtjc/www.nbjtjc.com;
            rewrite       ^view-(\d+)\.html /index.php?m=v&id=$1 last;
            rewrite       ~^([^?]+).html  /index.php?m=c&a=$1 last;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        location ~^([^?]+).html {
                root           /home/nbjtjc/www.nbjtjc.com;
                rewrite       ~^([^?]+).html  /index.php?m=c&a={R:1} last;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }
        location ~^([^?]+)-page(\d+)\.html {
                root           /home/nbjtjc/www.nbjtjc.com;
                rewrite       ~^([^?]+)-page(\d+)\.html  /index.php?m=c&a={R:1}&page={R:2} last;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }    

各位大神帮我看下吧

阅读 2k
2 个回答

第一行改为

location ~ ^/view-(\d+)\.html {

试试
还有下面的几行也不对。

你把所有的.html都重写为index.php?blabla=blabla带参数的,但是php代理配置那里匹配的是\.php$这里是不带参数的,你要配置成带参数的才行。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题