我在IE中得到了错误的URL,但在Firefox和Chrome中没有问题。
基本上,我有一个名为text-search的文本字段。我正在使用jQuery和htaccess中的rewriterule来内部重定向页面。我在localhost上,所有文件都在一个名为test的文件夹中。
在Firefox和Chrome中,如果您在text-search框中输入“hello”并按回车,“hi”并按回车以及“goodbye”并按回车,您将得到正确的URL: localhost/test/testing/hello
以及 localhost/test/testing/hi
以及 localhost/test/testing/goodbye 而在IE中,则会出现以下情况: localhost/test/testing/hello
以及 localhost/test/testing/testing/hi
以及 localhost/test/testing/testing/testing/goodbye 问题在于'testing'被添加了。如何防止在IE中发生这种情况。我在网上找不到解决此问题的答案。
以下是html和jquery代码:
基本上,我有一个名为text-search的文本字段。我正在使用jQuery和htaccess中的rewriterule来内部重定向页面。我在localhost上,所有文件都在一个名为test的文件夹中。
在Firefox和Chrome中,如果您在text-search框中输入“hello”并按回车,“hi”并按回车以及“goodbye”并按回车,您将得到正确的URL: localhost/test/testing/hello
以及 localhost/test/testing/hi
以及 localhost/test/testing/goodbye 而在IE中,则会出现以下情况: localhost/test/testing/hello
以及 localhost/test/testing/testing/hi
以及 localhost/test/testing/testing/testing/goodbye 问题在于'testing'被添加了。如何防止在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]
Can you please help me on this. Many thanks