問題:
Since I'm using react-router to handle my routes in a react app, I'm curious if there is a way to redirect to an external resource.由於我在 React 應用程序中使用 react-router 來處理我的路由,我很好奇是否有辦法重定向到外部資源。
Say someone hits:說有人打:
example.com/privacy-policy
I would like it to redirect to:我希望它重定向到:
example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies
I'm finding exactly zero help in avoiding writing it in plain JS at my index.html loading with something like:我發現在我的 index.html 加載中避免在純 JS 中編寫它的幫助爲零,例如:
if ( window.location.path === "privacy-policy" ){
window.location = "example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies"
}
解決方案:
參考一: https://en.stackoom.com/question/2u442參考二: https://stackoom.com/question/2u442