htaccess重写规则以隐藏获取变量停止Javascript xmlhttp.responseText
我重写了在url中隐藏GET变量的规则,但它干扰了一个Javascript函数,该函数将PHP文件读取到div中 htaccess文件如下所示:htaccess重写规则以隐藏获取变量停止Javascript xmlhttp.responseText,javascript,php,.htaccess,url-rewriting,xmlhttprequest,Javascript,Php,.htaccess,Url Rewriting,Xmlhttprequest,我重写了在url中隐藏GET变量的规则,但它干扰了一个Javascript函数,该函数将PHP文件读取到div中 htaccess文件如下所示: Options +FollowSymLinks -indexes <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / ## If the request is for a valid directory RewriteCond %{REQUEST_FILENAME} -d [O
Options +FollowSymLinks -indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
## If the request is for a valid directory
RewriteCond %{REQUEST_FILENAME} -d [OR]
## If the request is for a valid file
RewriteCond %{REQUEST_FILENAME} -f [OR]
## If the request is for a valid link
RewriteCond %{REQUEST_FILENAME} -l
## don't do anything
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ ?x=$1&z=$2&y=$3&r=$4 [L,NC,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ ?x=$1&z=$2&y=$3 [L,NC,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ ?x=$1&z=$2 [NC,L,QSA]
RewriteRule ^([^/]+)/?$ ?x=$1 [L,NC,QSA]
</IfModule>
function NextQ(qid, cor, ans, quiz, topic, age, Nm)
{
if (qid=="" && qid!="0")
{
document.getElementById("txtHint").innerHTML="hello";
return;
}
if(age==true)
{
age = document.getElementById("age").value;
}
if(Nm==true)
{
Nm = document.getElementById("Nm").value;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST", quiz, true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("qid=" + qid +"&ans="+ans +"&cor="+cor+"&topic="+topic+"&age="+age+"&Nm="+Nm);
}
javascript基本上发布到iquiz.php(称为quick的变量)并将响应放入Div中。问题是,当重写规则生效时,index.php会在Div中打开
我怎样才能阻止这种事情发生?我看不到Javascript发送url的方式
编辑
这源于我在htaccess规则中遇到的一个更大的问题,如果提供了无效的url,index.php会在其内部多次打开。在
Firebug
中运行它,然后查看Net
选项卡中的内容。我需要在php文件名之前添加../。谢谢关于编辑有什么想法吗?Bu无效的URL你是说404生成URL吗?我是说如果我关闭这些htaccess规则,你有,如果请求的是一个有效的文件规则,它将跳过无效PHP文件的这些规则,其余规则将不会触发。