gpt4 book ai didi

ubuntu - NGINX SEO 重写

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:44:31 25 4
gpt4 key购买 nike

我正在尝试使用 NGINX 重写一些用于 SEO 的 url。文件按原样下载。

website.com/games - 有效

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

关于ubuntu - NGINX SEO 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28999358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com