簡體   English   中英

如何重定向網頁並顯示新的 URL?

[英]how to redirect a web page and show the new URL?

我想將一個普通的 HTML 網頁重定向到一個新的 URL,但是我嘗試過的一切(元刷新、Javascript 重定向)都會導致舊 URL 出現在新頁面的地址欄中,即使在清除瀏覽器緩存之后也是如此。 .htaccess 重定向有時會起作用,但由於舊頁面已經是來自另一個域的重定向的目標這一事實而變得復雜。 我無權訪問主機帳戶。

任何人都可以建議一種方法來使新 URL 始終顯示在新頁面的地址欄中嗎? 非常感謝。

使用元刷新標簽應該可以正常工作。

 <meta http-equiv="refresh" content="0; url=http://example.com/" />

注意:將其放置在頭部部分。

您可能還想進行 javascript 重定向,因為 W3C 不推薦元標記方法,盡管它可能不適用於所有移動瀏覽器。 連同后備文本鏈接,這將使您的頁面類似於:

 <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="refresh" content="1; url=http://example.com"> <script type="text/javascript"> window.location.href = "http://example.com" </script> <title>Page Redirection</title> </head> <body> <!-- Note: don't tell people to `click` the link, just tell them that it is a link. --> If you are not redirected automatically, follow this <a href='http://example.com'>link to example</a>. </body> </html>

非常感謝上一個答案的答案: 從 HTML 頁面重定向

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM