本篇是系列文章,在看本文之前请先看:

百度智能小程序接入自然搜索的步骤解析(1)

百度智能小程序接入自然搜索的步骤解析(2)

百度智能小程序接入自然搜索的步骤解析(3)


配置示例

1、一对多映射关系示例

H5页面:

https://m.site.com/shop/123
https://shop.m.site.com/mshop/123


在app.json中配置url-mapping字段如下:

{
"pages": [
"pages/shop/shop"
],
"url-mapping": {
"pages/shop/shop":["/shop/${shopid}","https://shop.m.site.com/mshop/${shopid}"]
}
}

说明:
一对多的情况下,小程序路径对应一个数组。需要在智能小程序平台的H5域名配置主域名https://m.site.com, 在url-mapping配置规则中默认不写主域名;https://shop.m.site.com作为子域写在配置规则中。


2、一对一映射关系示例

在app.json中配置url-mapping字段如下:

{
"pages": [
"pages/index/index",
"pages/pb/pb",
"pages/frs/frs"
],
"url-mapping": {
"pages/index/index":"/",
"pages/pb/pb":"/p/${tid}",
"pages/frs/frs": "/?kw=${kw}"
}
}

说明:

百度贴吧智能小程序吧主页为 /pages/frs/frs?kw=baidu,

映射到百度贴吧的H5站点域名:https://tieba.baidu.com/?kw=baidu

百度贴吧智能小程序帖子详情页为 /pages/pb/pb?tid=5413837761

映射到百度贴吧的H5站点域名:https://tieba.baidu.com/p/5413837761


智能小程序平台配置url映射关系

首先进入智能小程序平台,进入小程序首页,单击“流量配置>自然搜索结果>URL Pattern”,即可对url映射规则进行线上配置。

url映射规则不仅可以在智能小程序平台中进行配置,也可以在app.json中进行配置,具体操作可以依据开发者的爱好而来。


联系电话:
1585150508*
QQ交谈:
小编
站长微信:
站长邮箱: service@qingjiuzhubei.com
41.75msRequest Duration2MBMemory UsageGET seoSchool/detail{id?}.htmlRouteAuth status
    • Booting (12.96ms)
    • Application (31.76ms)
      6 templates were rendered
      • site.zixun.seoDetail (resources/views/site/zixun/seoDetail.blade.php)9blade
        Params
        0
        cateAlls
        1
        newDetail
        2
        comment
        3
        hotnews
        4
        zuixinNews
        5
        xiangguan
        6
        t
        7
        d
        8
        k
      • layouts.site.layout (resources/views/layouts/site/layout.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • layouts.site.top (resources/views/layouts/site/top.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • layouts.site.bottom (resources/views/layouts/site/bottom.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • common.upgrade_vip (resources/views/common/upgrade_vip.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • kefu.kefu (resources/views/kefu/kefu.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      uri
      GET seoSchool/detail{id?}.html
      middleware
      web
      controller
      App\Http\Controllers\Site\ZixunController@seoSchoolDetail
      namespace
      App\Http\Controllers
      prefix
      /seoSchool
      where
      as
      seoSchoolDetail
      file
      app/Http/Controllers/Site/ZixunController.php:197-230
      8 statements were executed15.77ms
      • select * from `new_cates` where `pid` = '3' and `new_cates`.`deleted_at` is null3.59ms/app/Http/Controllers/Site/ZixunController.php:202zzshuju
        Metadata
        Bindings
        • 0. 3
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:202
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • select * from `news` where `news`.`id` = '26376' and `news`.`deleted_at` is null limit 1460μs/app/Http/Controllers/Site/ZixunController.php:203zzshuju
        Metadata
        Bindings
        • 0. 26376
        Hints
        • Use SELECT * only if you need all columns from table
        • LIMIT without ORDER BY causes non-deterministic results, depending on the query execution plan
        Backtrace
        • 14. /app/Http/Controllers/Site/ZixunController.php:203
        • 22. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 56. /public/index.php:53
      • select * from `new_cates` where `new_cates`.`id` in ('139') and `new_cates`.`deleted_at` is null440μs/app/Http/Controllers/Site/ZixunController.php:203zzshuju
        Metadata
        Bindings
        • 0. 139
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 19. /app/Http/Controllers/Site/ZixunController.php:203
        • 27. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 61. /public/index.php:53
      • select * from `news` where `news`.`deleted_at` is null order by `id` desc limit 101ms/app/Http/Controllers/Site/ZixunController.php:205zzshuju
        Metadata
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:205
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • select * from `news` where `news`.`deleted_at` is null order by `published_at` desc limit 10950μs/app/Http/Controllers/Site/ZixunController.php:206zzshuju
        Metadata
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:206
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • select * from `news` where `newscate_id` = '139' and `news`.`deleted_at` is null order by `id` asc limit 104.68ms/app/Http/Controllers/Site/ZixunController.php:208zzshuju
        Metadata
        Bindings
        • 0. 139
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:208
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • update `news` set `browse` = `browse` + 1, `updated_at` = '2025-09-23 11:22:31' where `id` = '26376' and `news`.`deleted_at` is null4.29ms/app/Http/Model/News/News.php:170zzshuju
        Metadata
        Bindings
        • 0. 2025-09-23 11:22:31
        • 1. 26376
        Backtrace
        • 12. /app/Http/Model/News/News.php:170
        • 13. /app/Http/Controllers/Site/ZixunController.php:210
        • 21. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 55. /public/index.php:53
      • select * from `comments` where `news_id` = '26376'360μs/app/Http/Controllers/Site/ZixunController.php:214zzshuju
        Metadata
        Bindings
        • 0. 26376
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:214
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
        web
        array:2 [ "name" => "Guest" "user" => array:1 [ "guest" => true ] ]
        api
        array:2 [ "name" => "Guest" "user" => array:1 [ "guest" => true ] ]
          _token
          EDTnCVJezC4ByeA6R1UtWiXjKzaqZQA6xuvKatft
          _previous
          array:1 [ "url" => "https://data.winndoo.cn/seoSchool/detail26376.html" ]
          PHPDEBUGBAR_STACK_DATA
          []
          format
          html
          content_type
          text/html; charset=UTF-8
          status_text
          OK
          status_code
          200
          request_query
          []
          request_request
          []
          request_headers
          array:17 [ "accept-encoding" => array:1 [ 0 => "gzip, deflate, br, zstd" ] "sec-ch-ua-plat...
          request_server
          array:41 [ "USER" => "apache" "HOME" => "/usr/share/httpd" "HTTP_ACCEPT_ENCODING" => "gzip, de...
          request_cookies
          []
          response_headers
          array:5 [ "cache-control" => array:1 [ 0 => "no-cache, private" ] "date" => array:1 [ ...
          path_info
          /seoSchool/detail26376.html
          session_attributes
          array:3 [ "_token" => "EDTnCVJezC4ByeA6R1UtWiXjKzaqZQA6xuvKatft" "_previous" => array:1 [ "u...