跳到正文
DEV Community· Ali T·· 5 小時前AI 評分31

網站遷移前如何建立重新導向對照表

How to Build a Redirect Map Before a Website Migration

AI 導讀

網站遷移前,應整理舊網址及其遷移後的目的地,並記錄每個網址預期的回應狀態,讓開發人員和編輯人員共用清單。先在測試環境核對重新導向的狀態碼、目的地及最終頁面,再於部署後在正式網域重做檢查;同時更新內部連結和網站地圖。

正文

Ali T

Disclosure: This article was drafted with AI assistance.

A redirect map is a list of old URLs and where each one should land after a migration. I’d start with the old sitemap, then add landing pages from analytics and URLs that still receive external links. The map gives developers and editors a shared checklist for launch day.

Record the expected outcome for each URL

Old path Expected response Destination
/docs/install_guide/ 301 /docs/install-guide/
/docs/getting-started/ 200 Same URL
/events/retired-event/ 410 None, if the page is permanently gone and has no replacement

For new paths, agree on a word separator before generating URLs from titles. If you’re considering changing slugs that already receive traffic, my GoogleDXB guide to hyphens and underscores in URLs explains what to weigh before scheduling that change.

Verify the first response and the final page

For the first row, request the old path with redirects disabled and check that the response is a 301 with the expected destination in the Location header. Then follow the redirect and check that the destination returns a 200 and displays the installation guide. A 200 on an unrelated page would still fail this check.

If the site relies on query parameters, add a separate row for a realistic example such as ?lang=en. Write down whether the parameter should survive the redirect and check the final URL against that expectation.

Rerun the same checks after launch

Run the checks on staging, then repeat them on the public hostname after deployment. Update internal links and the sitemap to use the final URLs. Keep the map with your release notes so the next migration can identify older paths that still need to work.

來源:DEV Community · dev.to