在.htaccess中重写url后,我在ajax的搜索结果中遇到问题 网址为
时,搜索工作正常http://www.sitename.com/movie.php?name=gold
但是现在在.htaccess中重写网址后,它存在一些错误
http://www.sitename.com/movie/gold
代码 .htaccess
RewriteEngine On
RewriteRule ^([^/.]+)$ $1.php [L]
# url movie rewrite
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+movie\.php\?name=([^\s&]+) [NC]
RewriteRule ^ movie/%1? [R=301,L]
RewriteRule ^movie/([^/]+)/?$ movie.php?name=$1 [L,QSA]
search.js
$(document).ready(function(){
$('.top-search input[type="text"]').on("keyup input", function(){
/* Get input value on change */
var inputVal = $(this).val();
var resultDropdown = $(this).siblings(".result");
if(inputVal.length){
$.get("search.php", {term: inputVal}).done(function(data)
{
// Display the returned data in browser
resultDropdown.html(data);
});
} else{
resultDropdown.empty();
}
});
// Set search input value on click of result item
$(document).on("click", ".result p", function(){
$(this).parents(".top-search").find('input[type="text"]').val($(this).text());
$(this).parent(".result").empty();
});
});