日期:2015-03-25 23:56:45
问题:
1.伪静态规则 RewriteRule ^(.*)/([a-z]+)-([a-z]+)-(.+)\.html$ $1/cha\.php\?com=$3&no=$4
2.静态后地址 / cha-qq-123456.html
对于PHP表单后提交的链接可以用规则进行伪静态,访问结果和动态的一样
但是通过表单直接提交的数据却无法进行伪静态
表单提交的数据总是后面有?号和key=参数,这样的值.
期望结果form表达提交后 地址变成cha-qq-123456.html类似状
网上搜了很久也没找到相关的文章
自己研究了才知道如此简单
解决:
使用js进行跳转url
js代码
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<script language="javascript">
function rwurl(myform){
if(myform.no.value!="")
{
window.location.href="cha-"+myform.com.value+"-"+removeWhitespace(myform.no.value)+".html";
}else{
window.location.href="cha-"+myform.com.value+".html";
}
}
function removeWhitespace(str) {
return str.replace(/[^0-9a-zA-Z]/g,"");
}
|
表单代码
1
2
3
4
5
|
<form method="get" >
<input type="hidden" name="com" value="qq" />
<input class="txt" name="no" type="text" maxlength="12" />
<input type="button" onclick="rwurl(this.form)" value="提交" />
</form>
|
值得注意的是 提交按钮一定要用 button 不能用submit
办公室:西安市未央区北三环大明宫建材市场
Copyright © 2007-2015 微风 所有权利 陕ICP备15001179号-1