我在以下地址:
http://www.example.com/#contact
成功聯絡表格提交後,用戶會被重定向到以下地址:
http://www.example.com/thanks
隨着下面的代碼幫助:
// Redirect to thank you page
redirect_to("thanks");
功能redirect_to的()定義爲:
// Page redirection
function redirect_to($url)
{
if(isset($url) && $url != '')
{
header("Location: " . $url);
exit();
}
}
的感謝頁面htaccess的規則是:
# Thanks Page
RewriteRule ^thanks/?$ thanks.php [QSA,L]
#RewriteRule ^thanks/$ thanks.php [QSA,L]
問題:
的問題是哈希(#)字符即片段部分仍然堅持URL:
http://www.example.com/thanks#contact
如果我將頁面重定向到thanks
,那麼#contact
部分如何與主URL保持一致?
我們如何通過htaccess或PHP甚至通過JS排除/放棄它?
您的解決方案在firefox中不起作用。 – user5307298