Php 如何从重写的url中删除变量并保留删除的url变量

Php 如何从重写的url中删除变量并保留删除的url变量,php,Php,我的索引页 <form id="myfom" action="x.php" method="get"> <fieldset> <select name="a1" id="a1"> <option value="o1">o1</option> <option value="o2">o2</option> </select> <select name="a2" id="a2"> <o

我的索引页

<form id="myfom" action="x.php" method="get">
<fieldset>

<select name="a1" id="a1">
<option value="o1">o1</option>
<option value="o2">o2</option>
</select>

<select name="a2" id="a2">
<option value="oo1">oo1</option>
<option value="oo2">oo2</option>
</select>

<select name="a3" id="a3">
<option value="ooo1">ooo1</option>
<option value="ooo2">ooo2</option>
</select>

<select name="a4" id="a4">
<option value="oooo1">oooo1</option>
<option value="oooo2">oooo2</option>
</select>

<select name="a5" id="a5">
<option value="ooooo1">ooooo1</option>
<option value="ooooo2">ooooo2</option>
</select>

<select name="a6" id="a6">
<option value="oooooo1">oooooo1</option>
<option value="oooooo2">oooooo2</option>
</select>


<script type="text/javascript">
function murl() {
    var grp1 = document.getElementById('a1').options[document.getElementById('a1').selectedIndex].value;
    var grp2 = document.getElementById('a2').options[document.getElementById('a2').selectedIndex].value;
    var grp3 = document.getElementById('a3').options[document.getElementById('a3').selectedIndex].value;
    var grp4 = document.getElementById('a4').options[document.getElementById('a4').selectedIndex].value;
    var grp5 = document.getElementById('a5').options[document.getElementById('a5').selectedIndex].value;
    var grp6 = document.getElementById('a6').options[document.getElementById('a6').selectedIndex].value ;
    var url = "http://www.domain.com/"+grp1+"-"+grp2+"-"+grp3+"-"+grp4+"-"+grp5+"-"+grp6+".html";

    document.forms["myform"].submit();
    window.location.href=url;
}
</script>
<input type="button" onclick="murl()" />
</fieldset>
</form>
网站是这样工作的;

这是我的问题; 我想要像这样的网址

但我还想在新页面上获取变量a4、a5、a6(在将表单提交到x.php之后)

尝试了很多方法,比如重写cond%{QUERY_STRING}, 任何帮助都将是巨大的


这是不可能的,至少不能直接做到。如果你从URL中删除内容,它就会消失

您必须使用完整URL调用PHP脚本
a1-a2-a3-a4-a5-a6.html
,将a4-a6存储在中,并重定向到
a1-a2-a3.html
。但是,如果同一个用户代理发出多个请求,则会导致问题-要解决此问题,您还可以在目标页面上检查
$\u SERVER[“HTTP\u REFERER”]


两者都相当复杂。你确定你需要这个吗?

哇,谢谢你的快速回答,但这应该是一种方式。。php会话怎么样?我们不能用get方法发送不可见变量吗?@qxygene否,get没有不可见变量。如前所述,唯一的方法是会话或在重定向完成后从
a1-a2-a3.html
检查referer头。但这很复杂,我不会为了一个漂亮的URL而这么做
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html$ x.php?a1=$1&a2=$2&a3=$3&a4=$4&a5=$5&a6=$6 [L,QSA]