我的網址錯誤,但在IE瀏覽器中,但不是在Firefox和鉻。爲什麼window.location追加而不是替換在ie
基本上,我有一個稱爲文本搜索的文本框。我在htaccess中使用jQuery和rewriterule來內部重定向頁面。我在本地主機上,所有文件都位於名爲test的文件夾中。
在Firefox和Chrome,如果你輸入「你好」按下回車鍵,「嗨」回車,「再見」打在文本搜索框中輸入你得到了正確的網址爲
本地主機/測試/測試/你好
和
本地主機/測試/檢驗/喜
和
本地主機/測試/檢驗/再見
分別。
在IE中你得到
本地主機/測試/測試/你好
和
本地主機/測試/檢驗/檢測/喜
和
本地主機/測試/測試/測試/測試/再見
分別爲
這裏的問題是「測試」是預先考慮的。如何阻止這種情況發生在ie。我無法在網上找到這個問題的答案。
HTML和jQuery代碼
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<base href="http://localhost/test/" />
<script src="jQuery.js"></script>
<script>
$(document).ready(function(){
$("#text-search").keyup(function(e){
if (e.keyCode == 13){
window.location.replace("testing/"+$('#text-search').val());
}
})
})
</script>
</head>
<body>
<input type='text' id='text-search'>
</body>
</html>
的.htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^testing/(.+)$ /test/testing.php?string=$1 [L]
能否請你幫我在這。非常感謝
你好,感謝你的幫助。我只是將正則表達式更改爲/testing.*$/,因爲最初我有localhost/test/testing.php和後綴,我得到本地主機/測試/測試/ ...,對不起,以上沒有說清楚。它工作正常。再次感謝。 – Hani