form表单提交数据时如何使url伪静态化
时间:2015-01-11 来源:服务器在线 投稿:泡泡 点击:次
问题:
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代码
<script language="javascript">
function rwurl(myform){
if(myform.no.value!="")
{
window.location.href="http://www.skyfox.org/cha-"+myform.com.value+"-"+removeWhitespace(myform.no.value)+".html";
}else{
window.location.href="http://www.skyfox.org/cha-"+myform.com.value+".html";
}
}
function removeWhitespace(str) {
return str.replace(/[^0-9a-zA-Z]/g,"");
}
表单代码
<form method="get" >
<input type="hidden" name="com" value="qq" />
<input name="no" type="text" maxlength="12" />
<input type="button" value="提交" />
</form>
值得注意的是 提交按钮一定要用 button 不能用submit
....完!
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代码
<script language="javascript">
function rwurl(myform){
if(myform.no.value!="")
{
window.location.href="http://www.skyfox.org/cha-"+myform.com.value+"-"+removeWhitespace(myform.no.value)+".html";
}else{
window.location.href="http://www.skyfox.org/cha-"+myform.com.value+".html";
}
}
function removeWhitespace(str) {
return str.replace(/[^0-9a-zA-Z]/g,"");
}
<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,""); } |
<form method="get" >
<input type="hidden" name="com" value="qq" />
<input name="no" type="text" maxlength="12" />
<input type="button" value="提交" />
</form>
<form method="get" > <input type="hidden" name="com" value="qq" /> <input name="no" type="text" maxlength="12" /> <input type="button" value="提交" /> </form> |
如果您的问题仍未解决,还可以加入服务器在线技术交流QQ群:8017413寻求帮助。
上一篇:没有了
下一篇:PHP程序使用正则过滤html标签、空格、换行符
下一篇:PHP程序使用正则过滤html标签、空格、换行符
相关内容
最新热点内容
推荐内容