努力使用 301 重定向規則以忽略其他 URL 段。這是目標:
以這種格式重定向 URL:example.com/product-category/category-parent/category-child/到一個新的目標 URL。
這是 中的規則.htaccess:
Redirect 301 /product-category/category-parent/category-child/ https://newurl.com/
重定向進行得很好,除了 URL 的子段通過新 URL 傳遞,所以我最終得到newurl/category-child/的是 404。
編輯:嘗試使用RedirectMatch幾個特定的??嵌套類別 URL,但沒有成功:
RedirectMatch 301 /product-category/parent/child/ https://newurl.com/
仍然產生https://newurl.com/child404。
uj5u.com熱心網友回復:
整理出如何做我需要的事情。ApacheRedirectMatch是我需要的正確正則運算式。
RedirectMatch permanent "^/product-category/(.*)" "https://newurl.com/"
這將匹配/product-category/段之后的任意數量的任意字符并重定向到新的目標 URL,這正是我所需要的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/424276.html
