Ubuntu NGINX搜索引擎优化重写

Ubuntu NGINX搜索引擎优化重写,ubuntu,nginx,seo,server,Ubuntu,Nginx,Seo,Server,我正试图用NGINX重写一些搜索引擎优化的URL。文件正在按原样下载 website.com/games-Works website.com/games/game-title/1-作品 website.com/games/game-title/1/news-下载PHP文件 location / { rewrite ^/games?$ /games.php last; } location /games/ { rewrite ^/game

我正试图用NGINX重写一些搜索引擎优化的URL。文件正在按原样下载

website.com/games-Works

website.com/games/game-title/1-作品

website.com/games/game-title/1/news-下载PHP文件

location / {
    rewrite ^/games?$ /games.php last;
  }         

  location /games/ {        
    rewrite ^/games/([^/]+?)/([0-9]+)? /game.php?id=$2 break; 
    rewrite ^/games/([^/]+?)/([0-9]+)?/news /game.php?id=$2&show=news last;        
  }   

我会这样写:

rewrite ^/games/? /games.php;

location /games/ {
    rewrite ^/games/([^/]+)/([0-9]+)/news /game.php?id=$2&show=news last;
    rewrite ^/games/([^/]+)/([0-9]+)      /game.php?id=$2           last;
}

location ~ \.php$ {
    ... php stuff ...
}

据我所见,最后两个URL都应该下载php。但是无论如何,你把
break
last
标志搞砸了。它会以普通视图将php文件下载到我电脑的硬盘上。安全风险大。