找回密碼
 註冊
搜索
查看: 39|回復: 0

[教學] opencart 4.0.2.3 如何安裝sitemap

[複製鏈接]
發表於 昨天 22:40 | 顯示全部樓層 |閱讀模式
Push to Facebook
1.先去opencart官網下載 tmdfeed.ocmod.zip

2. 到opencart後台安裝模組
擴充模組安裝上傳

opencart sitemap

opencart sitemap

前往 擴充模組管理 -> 擴充模組 (Extensions)。
下拉選擇 Feeds (訂閱/Feed)。
啟用 Google Sitemap。

opencart sitemap

opencart sitemap



如遇亂碼
TMD 模組 Controller 中的 Content-Type 與輸出邏輯修復
請打開該模組控制器 catalog/controller/extension/tmdfeed/feed/google_sitemap.php,查看輸出部分的程式碼。
通常正確的 XML 輸出必須包含正確的 Content-Type 標頭:
  1. // 必須在 setOutput 之前加上這行
  2. $this->response->addHeader('Content-Type: application/xml; charset=utf-8');

  3. $this->response->setOutput($output);
複製代碼


2. 在 Google Search Console 中使用了動態網址(帶 ? 號)
直接提交包含 index.php?route=... 的動態網址,有時候會因為 OpenCart 的 URL 重寫機制或 Google 對帶參數網址的快取問題而抓取失敗。
  • 修正方法:請透過 .htaccess 或 OpenCart 後台的 SEO URL 將 Sitemap 綁定為靜態網址:

    • 開啟根目錄下的 .htaccess 檔案,新增以下重寫規則:
      1. # 將 /sitemap.xml 導向至 TMD Sitemap 模組
      2. RewriteRule ^sitemap\.xml$ index.php?route=extension/tmdfeed/feed/google_sitemap [L]
      複製代碼

    • 在瀏覽器輸入 [https://mypresent.net/sitemap.xml](https://mypresent.net/sitemap.xml) 測試是否能正常開啟。
    • 前往 Google Search Console,改為提交 sitemap.xml。

3. robots.txt 未寫入 Sitemap 路徑
Google 爬蟲在抓取 Sitemap 前會先讀取 robots.txt。
修正方法:編輯網站根目錄下的 robots.txt,在最下方加入:


  1. Sitemap: https://mypresent.net/sitemap.xml
複製代碼

opencart sitemap

opencart sitemap
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2026-10-13 00:02 , Processed in 0.025901 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表