环境运维

nginx url rewrite伪静态

server {
    listen 80;
    server_name example.com;
 
    location / {
        root /var/www/html;
        index index.html index.php;
    }
 
    location ~ ^/article/([0-9]+)$ {
        rewrite ^/article/([0-9]+)$ /index.php?id=$1 last;
    }

   location ~ ^/cat/(\d+)$ {
     rewrite ^/cat/(\d+)$ /index.php?v=listing&cid=$1 last;
   }
 
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}