Nginx rewrite configuration

the rewrite configuration on iis is like this

my configuration on nginx is like this, but except for index.php and / directory, everything else is file not found. It must be my configuration problem

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;
        }    

Gods, please take a look at it for me

Apr.02,2021

change the first line to

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

try
and the following lines are also wrong.


you rewrite all .html as index.php?blabla=blabla with parameters, but the php proxy configuration matches \ .php $. You have to configure it with parameters.

Menu