arcade_cms_gamemonetize在nginx下的配置

  PHP

arcade_cms_gamemonetize默认是在apache下运行的,通过以下路由配置,可以在nginx下正常运行

location / {
    try_files $uri $uri/ @rewrite;  # 优先检查文件/目录是否存在
}

location @rewrite {
    # 基础路由规则(按原顺序转换)
    rewrite ^/home(|/)$ /index.php?p=home last;
    rewrite ^/feed(|/)$ /feed.php last;
    rewrite ^/new-games(|/)$ /index.php?p=new-games last;
    rewrite ^/best-games(|/)$ /index.php?p=best-games last;
    rewrite ^/random(|/)$ /index.php?p=random last;
    rewrite ^/about(|/)$ /index.php?p=about last;
    rewrite ^/tags(|/)$ /index.php?p=tags last;
    rewrite ^/privacy(|/)$ /index.php?p=privacy last;
    rewrite ^/terms(|/)$ /index.php?p=terms last;
    rewrite ^/contact(|/)$ /index.php?p=contact last;
    rewrite ^/featured-games(|/)$ /index.php?p=featured-games last;
    rewrite ^/played-games(|/)$ /index.php?p=played-games last;
    rewrite ^/categories(|/)$ /index.php?p=categories last;
    rewrite ^/blogs(|/)$ /index.php?p=blogs last;
    rewrite ^/login(|/)$ /index.php?p=login last;
    
    # 带参数路由
    rewrite ^/logout/(.*)$ /index.php?p=logout&token=$1 last;
    rewrite ^/login/url/(.*)$ /index.php?p=login&redirect_url=$1 last;
    rewrite ^/category/(.*)$ /index.php?p=categories&category=$1 last;
    rewrite ^/blog/(.*)$ /index.php?p=blogs&blog=$1 last;
    rewrite ^/tag/(.*)$ /index.php?p=tagspage&tag=$1 last;
    rewrite ^/profile/(.*)$ /index.php?p=profile&id=$1 last;
    rewrite ^/game/(.*)$ /index.php?p=play&id=$1 last;
    rewrite ^/search/(.*)$ /index.php?p=search&q=$1 last;
    rewrite ^/search-handler/(.*)$ /index.php?p=search-handler&q=$1 last;
    
    # 特殊路由(带正则捕获)
    rewrite ^/([A-Za-z0-9-.]+)-games$ /index.php?cat=$1 last;  # [7](@ref)
}

location @rewrite {
    # 管理员基础路由
    rewrite ^/admin(|/)$ /index.php?p=admin&section=global last;
    rewrite ^/admin/addgame(|/)$ /index.php?p=admin&section=addgame last;
    rewrite ^/admin/setting(|/)$ /index.php?p=admin&section=setting last;
    rewrite ^/admin/games(|/)$ /index.php?p=admin&section=games last;
    rewrite ^/admin/games-images-and-videos(|/)$ /index.php?p=admin&section=games-images-and-videos last;
    
    # 带ID的编辑路由
    rewrite ^/admin/users/edit/(.*)$ /index.php?p=admin&section=users&action=edit&uid=$1 last;
    rewrite ^/admin/categories/edit/(.*)$ /index.php?p=admin&section=categories&action=edit&cid=$1 last;
    rewrite ^/admin/blogs/edit/(.*)$ /index.php?p=admin&section=blogs&action=edit&cid=$1 last;
    rewrite ^/admin/tags/edit/(.*)$ /index.php?p=admin&section=tags&action=edit&cid=$1 last;
    rewrite ^/admin/sliders/edit/(.*)$ /index.php?p=admin&section=sliders&action=edit&cid=$1 last;
    
    # 分页路由
    rewrite ^/admin/games/(.*)$ /index.php?p=admin&section=games&page=$1 last;
}

location @rewrite {
    # API路由
    rewrite ^/api/v1/sandbox/game/(.*)$ /gm-api.php?l=game-sandbox&gid=$1 last;
    
    # 公开链接路由
    rewrite ^/links/rEYdh7jWtqIwJCfgaG6H1LNS4VvyBoP5mQTbOs2l$ /index.php?p=public last;
    rewrite ^/links_old_games/HLdsx7baSp2WlByVRf61CIZwmG9KOvA5toDceYNU$ /index.php?p=public last;
}

LEAVE A COMMENT