·设为首页收藏本站📧邮箱修改🎁免费下载专区📒收藏夹📱AI全功能
12下一页
返回列表 发布新帖

谁能把Apache规则直接转换成Nginx规则

78 11
发表于 5 小时前 | 查看全部 阅读模式

马上注册,免费下载更多dz插件网资源。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
<IfModule mod_rewrite.c>
    RewriteEngine On
    AddDefaultCharset UTF-8
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^search/(.*)$ /index.php?c=index&m=search&keywords=$1 [L,QSA]
    RewriteRule ^download.html$ /index.php?c=index&m=high_speed_download [L,QSA]
    RewriteRule ^info/([0-9]+).html$ /index.php?c=index&m=info_list&last_cate_id=$1 [L,QSA]
    RewriteRule ^game/([0-9]+).html$ /index.php?c=index&m=game_list&cate_id=$1 [L,QSA]
    RewriteRule ^soft/([0-9]+).html$ /index.php?c=index&m=soft_list&cate_id=$1 [L,QSA]
    RewriteRule ^necessary/([0-9]+).html$ /index.php?c=index&m=necessary_list&necessary_type=$1 [L,QSA]
    RewriteRule ^games/([0-9]+).html$ /index.php?c=index&m=game_more&cate_id=$1 [L,QSA]
    RewriteRule ^softs/([0-9]+).html$ /index.php?c=index&m=soft_more&cate_id=$1 [L,QSA]
    RewriteRule ^map.html$ /index.php?c=index&m=site_map [L,QSA]
    RewriteRule ^searchs.html$ /index.php?c=index&m=page_search [L,QSA]
    RewriteRule ^xcode.html$ /index.php?c=index&m=xcode [L,QSA]
    RewriteRule ^rank.html$ /index.php?c=index&m=list_rank [L,QSA]
    RewriteRule ^special.html$ /index.php?c=index&m=list_special [L,QSA]
    RewriteRule ^info.html$ /index.php?c=index&m=list_info [L,QSA]
    RewriteRule ^necessary.html$ /index.php?c=index&m=list_necessary [L,QSA]
    RewriteRule ^game.html$ /index.php?c=index&m=list_game [L,QSA]
    RewriteRule ^soft.html$ /index.php?c=index&m=list_soft [L,QSA]
    RewriteRule ^category/([0-9]+).html$ /index.php?c=index&m=list_category&cate_id=$1 [L,QSA]
    RewriteRule ^comment/([0-9]+).html$ /index.php?c=index&m=comment&app_id=$1 [L,QSA]
    RewriteRule ^qrcode/([0-9]+).html$ /index.php?c=index&m=qrcode&app_id=$1 [L,QSA]
    RewriteRule ^recommend/([0-9]+).html$ /index.php?c=index&m=list_recommend&id=$1 [L,QSA]
    RewriteRule ^download/([0-9]+).html$ /index.php?c=index&m=download&app_id=$1 [L,QSA]
    RewriteRule ^special/([0-9]+).html$ /index.php?c=index&m=content_special&special_id=$1 [L,QSA]
    RewriteRule ^news/([0-9]+).html$ /index.php?c=index&m=content_info&info_id=$1 [L,QSA]
    RewriteRule ^softs.html$ /index.php?c=index&m=more_soft [L,QSA]
    RewriteRule ^games.html$ /index.php?c=index&m=more_game [L,QSA]
    RewriteRule ^app/([0-9]+).html$ /index.php?c=index&m=content_app&app_id=$1 [L,QSA]
</IfModule>
谁能把上面的Apache规则直接转换成Nginx规则
我要说一句 收起回复

评论11

拾光Lv.8 发表于 5 小时前 | 查看全部
试试这个,不行的话问AI
  1. if (!-f $request_filename){        set $rule_0 1$rule_0;}if (!-d $request_filename){        set $rule_0 2$rule_0;}if ($rule_0 = "21"){        rewrite ^/search/(.*)$ /index.php?c=index&m=search&keywords=$1 last;}        rewrite ^/download.html$ /index.php?c=index&m=high_speed_download last;        rewrite ^/info/([0-9]+).html$ /index.php?c=index&m=info_list&last_cate_id=$1 last;        rewrite ^/game/([0-9]+).html$ /index.php?c=index&m=game_list&cate_id=$1 last;        rewrite ^/soft/([0-9]+).html$ /index.php?c=index&m=soft_list&cate_id=$1 last;        rewrite ^/necessary/([0-9]+).html$ /index.php?c=index&m=necessary_list&necessary_type=$1 last;        rewrite ^/games/([0-9]+).html$ /index.php?c=index&m=game_more&cate_id=$1 last;        rewrite ^/softs/([0-9]+).html$ /index.php?c=index&m=soft_more&cate_id=$1 last;        rewrite ^/map.html$ /index.php?c=index&m=site_map last;        rewrite ^/searchs.html$ /index.php?c=index&m=page_search last;        rewrite ^/xcode.html$ /index.php?c=index&m=xcode last;        rewrite ^/rank.html$ /index.php?c=index&m=list_rank last;        rewrite ^/special.html$ /index.php?c=index&m=list_special last;        rewrite ^/info.html$ /index.php?c=index&m=list_info last;        rewrite ^/necessary.html$ /index.php?c=index&m=list_necessary last;        rewrite ^/game.html$ /index.php?c=index&m=list_game last;        rewrite ^/soft.html$ /index.php?c=index&m=list_soft last;        rewrite ^/category/([0-9]+).html$ /index.php?c=index&m=list_category&cate_id=$1 last;        rewrite ^/comment/([0-9]+).html$ /index.php?c=index&m=comment&app_id=$1 last;        rewrite ^/qrcode/([0-9]+).html$ /index.php?c=index&m=qrcode&app_id=$1 last;        rewrite ^/recommend/([0-9]+).html$ /index.php?c=index&m=list_recommend&id=$1 last;        rewrite ^/download/([0-9]+).html$ /index.php?c=index&m=download&app_id=$1 last;        rewrite ^/special/([0-9]+).html$ /index.php?c=index&m=content_special&special_id=$1 last;        rewrite ^/news/([0-9]+).html$ /index.php?c=index&m=content_info&info_id=$1 last;        rewrite ^/softs.html$ /index.php?c=index&m=more_soft last;        rewrite ^/games.html$ /index.php?c=index&m=more_game last;        rewrite ^/app/([0-9]+).html$ /index.php?c=index&m=content_app&app_id=$1 last;
复制代码
我要说一句 收起回复
回复 支持 反对

使用道具 举报

IT618发布Lv.8 发表于 5 小时前 | 查看全部
丢给ai不就行了嘛........

charset utf-8;

location / {
    try_files $uri $uri/ @rewrite_rules;
}

location @rewrite_rules {
    rewrite ^/search/(.*)$ /index.php?c=index&m=search&keywords=$1 last;
    rewrite ^/download\.html$ /index.php?c=index&m=high_speed_download last;
    rewrite ^/info/([0-9]+)\.html$ /index.php?c=index&m=info_list&last_cate_id=$1 last;
    rewrite ^/game/([0-9]+)\.html$ /index.php?c=index&m=game_list&cate_id=$1 last;
    rewrite ^/soft/([0-9]+)\.html$ /index.php?c=index&m=soft_list&cate_id=$1 last;
    rewrite ^/necessary/([0-9]+)\.html$ /index.php?c=index&m=necessary_list&necessary_type=$1 last;
    rewrite ^/games/([0-9]+)\.html$ /index.php?c=index&m=game_more&cate_id=$1 last;
    rewrite ^/softs/([0-9]+)\.html$ /index.php?c=index&m=soft_more&cate_id=$1 last;
    rewrite ^/map\.html$ /index.php?c=index&m=site_map last;
    rewrite ^/searchs\.html$ /index.php?c=index&m=page_search last;
    rewrite ^/xcode\.html$ /index.php?c=index&m=xcode last;
    rewrite ^/rank\.html$ /index.php?c=index&m=list_rank last;
    rewrite ^/special\.html$ /index.php?c=index&m=list_special last;
    rewrite ^/info\.html$ /index.php?c=index&m=list_info last;
    rewrite ^/necessary\.html$ /index.php?c=index&m=list_necessary last;
    rewrite ^/game\.html$ /index.php?c=index&m=list_game last;
    rewrite ^/soft\.html$ /index.php?c=index&m=list_soft last;
    rewrite ^/category/([0-9]+)\.html$ /index.php?c=index&m=list_category&cate_id=$1 last;
    rewrite ^/comment/([0-9]+)\.html$ /index.php?c=index&m=comment&app_id=$1 last;
    rewrite ^/qrcode/([0-9]+)\.html$ /index.php?c=index&m=qrcode&app_id=$1 last;
    rewrite ^/recommend/([0-9]+)\.html$ /index.php?c=index&m=list_recommend&id=$1 last;
    rewrite ^/download/([0-9]+)\.html$ /index.php?c=index&m=download&app_id=$1 last;
    rewrite ^/special/([0-9]+)\.html$ /index.php?c=index&m=content_special&special_id=$1 last;
    rewrite ^/news/([0-9]+)\.html$ /index.php?c=index&m=content_info&info_id=$1 last;
    rewrite ^/softs\.html$ /index.php?c=index&m=more_soft last;
    rewrite ^/games\.html$ /index.php?c=index&m=more_game last;
    rewrite ^/app/([0-9]+)\.html$ /index.php?c=index&m=content_app&app_id=$1 last;
}
我要说一句 收起回复
回复 支持 反对

使用道具 举报

拾光Lv.8 发表于 5 小时前 | 查看全部
真实惭愧啊,看不懂
我要说一句 收起回复
回复 支持 反对

使用道具 举报

CrystαlLv.8 发表于 5 小时前 | 查看全部
去AI。。。
我要说一句 收起回复
回复 支持 反对

使用道具 举报

拾光Lv.8 发表于 5 小时前 | 查看全部
有问题找AI。。
我要说一句 收起回复
回复 支持 反对

使用道具 举报

婷姐Lv.8 发表于 5 小时前 | 查看全部
有问题找AI
我要说一句 收起回复
回复 支持 反对

使用道具 举报

婷姐Lv.8 发表于 5 小时前 | 查看全部
# 对应 AddDefaultCharset UTF-8
charset utf-8;

# 对应 RewriteCond %{REQUEST_FILENAME} !-f 和 !-d (仅作用于第一条 /search/ 规则)
if (!-e $request_filename) {
    rewrite ^/search/(.*)$ /index.php?c=index&m=search&keywords=$1 last;
}

# 以下规则无文件/目录检测,直接重写(原 Apache 行为)
rewrite ^/download\.html$                                  /index.php?c=index&m=high_speed_download        last;
rewrite ^/info/([0-9]+)\.html$                            /index.php?c=index&m=info_list&last_cate_id=$1  last;
rewrite ^/game/([0-9]+)\.html$                            /index.php?c=index&m=game_list&cate_id=$1        last;
rewrite ^/soft/([0-9]+)\.html$                            /index.php?c=index&m=soft_list&cate_id=$1        last;
rewrite ^/necessary/([0-9]+)\.html$                       /index.php?c=index&m=necessary_list&necessary_type=$1 last;
rewrite ^/games/([0-9]+)\.html$                           /index.php?c=index&m=game_more&cate_id=$1        last;
rewrite ^/softs/([0-9]+)\.html$                           /index.php?c=index&m=soft_more&cate_id=$1        last;
rewrite ^/map\.html$                                      /index.php?c=index&m=site_map                     last;
rewrite ^/searchs\.html$                                  /index.php?c=index&m=page_search                   last;
rewrite ^/xcode\.html$                                    /index.php?c=index&m=xcode                         last;
rewrite ^/rank\.html$                                     /index.php?c=index&m=list_rank                     last;
rewrite ^/special\.html$                                  /index.php?c=index&m=list_special                  last;
rewrite ^/info\.html$                                     /index.php?c=index&m=list_info                     last;
rewrite ^/necessary\.html$                                /index.php?c=index&m=list_necessary                last;
rewrite ^/game\.html$                                     /index.php?c=index&m=list_game                     last;
rewrite ^/soft\.html$                                     /index.php?c=index&m=list_soft                     last;
rewrite ^/category/([0-9]+)\.html$                        /index.php?c=index&m=list_category&cate_id=$1      last;
rewrite ^/comment/([0-9]+)\.html$                         /index.php?c=index&m=comment&app_id=$1             last;
rewrite ^/qrcode/([0-9]+)\.html$                          /index.php?c=index&m=qrcode&app_id=$1              last;
rewrite ^/recommend/([0-9]+)\.html$                       /index.php?c=index&m=list_recommend&id=$1          last;
rewrite ^/download/([0-9]+)\.html$                        /index.php?c=index&m=download&app_id=$1            last;
rewrite ^/special/([0-9]+)\.html$                         /index.php?c=index&m=content_special&special_id=$1 last;
rewrite ^/news/([0-9]+)\.html$                            /index.php?c=index&m=content_info&info_id=$1       last;
rewrite ^/softs\.html$                                    /index.php?c=index&m=more_soft                     last;
rewrite ^/games\.html$                                    /index.php?c=index&m=more_game                     last;
rewrite ^/app/([0-9]+)\.html$                             /index.php?c=index&m=content_app&app_id=$1         last;
我要说一句 收起回复
回复 支持 反对

使用道具 举报

IT618发布Lv.8 发表于 5 小时前 | 查看全部
直接ai多简单
我要说一句 收起回复
回复 支持 反对

使用道具 举报

浅生Lv.8 发表于 5 小时前 | 查看全部
server {
    listen 80;
    server_name 你的域名.com www.你的域名.com; # 替换成你的实际域名
    root D:/phpstudy_pro/WWW/你的网站目录; # 替换成你的网站实际根目录
    index index.html index.htm index.php;

    charset utf-8;

    # 静态文件缓存(提升性能)
    location ~* \.(gif|jpg|jpeg|png|bmp|swf|ico|css|js)$ {
        expires 30d;
        access_log off;
    }

    location / {
        # 核心逻辑:先尝试访问真实文件/目录,不存在则走重写规则
        try_files $uri $uri/ @rewrite;
    }

    location @rewrite {
        # 搜索
        rewrite ^/search/(.*)$ /index.php?c=index&m=search&keywords=$1 last;
        
        # 下载页
        rewrite ^/download.html$ /index.php?c=index&m=high_speed_download last;
        
        # 信息列表
        rewrite ^/info/([0-9]+).html$ /index.php?c=index&m=info_list&last_cate_id=$1 last;
        
        # 游戏列表
        rewrite ^/game/([0-9]+).html$ /index.php?c=index&m=game_list&cate_id=$1 last;
        
        # 软件列表
        rewrite ^/soft/([0-9]+).html$ /index.php?c=index&m=soft_list&cate_id=$1 last;
        
        # 必备列表
        rewrite ^/necessary/([0-9]+).html$ /index.php?c=index&m=necessary_list&necessary_type=$1 last;
        
        # 游戏更多
        rewrite ^/games/([0-9]+).html$ /index.php?c=index&m=game_more&cate_id=$1 last;
        
        # 软件更多
        rewrite ^/softs/([0-9]+).html$ /index.php?c=index&m=soft_more&cate_id=$1 last;
        
        # 地图
        rewrite ^/map.html$ /index.php?c=index&m=site_map last;
        
        # 搜索页
        rewrite ^/searchs.html$ /index.php?c=index&m=page_search last;
        
        # XCode
        rewrite ^/xcode.html$ /index.php?c=index&m=xcode last;
        
        # 排行
        rewrite ^/rank.html$ /index.php?c=index&m=list_rank last;
        
        # 专题列表
        rewrite ^/special.html$ /index.php?c=index&m=list_special last;
        
        # 资讯列表
        rewrite ^/info.html$ /index.php?c=index&m=list_info last;
        
        # 必备列表
        rewrite ^/necessary.html$ /index.php?c=index&m=list_necessary last;
        
        # 游戏列表
        rewrite ^/game.html$ /index.php?c=index&m=list_game last;
        
        # 软件列表
        rewrite ^/soft.html$ /index.php?c=index&m=list_soft last;
        
        # 分类
        rewrite ^/category/([0-9]+).html$ /index.php?c=index&m=list_category&cate_id=$1 last;
        
        # 评论
        rewrite ^/comment/([0-9]+).html$ /index.php?c=index&m=comment&app_id=$1 last;
        
        # 二维码
        rewrite ^/qrcode/([0-9]+).html$ /index.php?c=index&m=qrcode&app_id=$1 last;
        
        # 推荐
        rewrite ^/recommend/([0-9]+).html$ /index.php?c=index&m=list_recommend&id=$1 last;
        
        # 下载
        rewrite ^/download/([0-9]+).html$ /index.php?c=index&m=download&app_id=$1 last;
        
        # 专题内容
        rewrite ^/special/([0-9]+).html$ /index.php?c=index&m=content_special&special_id=$1 last;
        
        # 新闻内容
        rewrite ^/news/([0-9]+).html$ /index.php?c=index&m=content_info&info_id=$1 last;
        
        # 软件更多 (无参数)
        rewrite ^/softs.html$ /index.php?c=index&m=more_soft last;
        
        # 游戏更多 (无参数)
        rewrite ^/games.html$ /index.php?c=index&m=more_game last;
        
        # APP内容
        rewrite ^/app/([0-9]+).html$ /index.php?c=index&m=content_app&app_id=$1 last;
    }

    # phpStudy 默认 PHP 处理配置(支持所有PHP版本切换)
    location ~ \.php(.*)$ {
        fastcgi_pass 127.0.0.1:9000; # phpStudy 切换PHP版本会自动修改这个端口
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    }

    # 禁止访问 .htaccess 文件
    location ~ /\.ht {
        deny all;
    }

    # 日志配置(可选,如需开启取消注释)
    # access_log D:/phpstudy_pro/Extensions/Nginx/logs/你的网站_access.log;
    # error_log D:/phpstudy_pro/Extensions/Nginx/logs/你的网站_error.log;
}phpStudy 面板使用步骤
    打开 phpStudy 面板 → 点击左侧「网站」找到你的网站 → 点击右侧「管理」→「配置文件」全选删除原有内容,粘贴上面的配置修改前 3 行的域名和根目录为你的实际信息保存配置 → 重启 Nginx 服务
我要说一句 收起回复
回复 支持 反对

使用道具 举报

回复

 懒得打字嘛,点击右侧快捷回复【查看最新发布】   【应用商城享更多资源】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

图文热点
关闭

站长推荐上一条 /1 下一条

最新热评 加载中...
AI智能体
投诉/建议联系

discuzaddons@vip.qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,按照公告处理!!!
  • 联系QQ客服
  • 添加微信客服

联系DZ插件网微信客服|最近更新|Archiver|手机版|小黑屋|DZ插件网! ( 鄂ICP备20010621号-1 )|网站地图 知道创宇云防御

您的IP:216.73.216.200,GMT+8, 2026-4-25 16:05 , Processed in 1.763825 second(s), 124 queries , Gzip On, Redis On.

Powered by Discuz! X5.1 Licensed

© 2001-2026 Discuz! Team.

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表