将多个可选的$ _GET参数转换为清理URL [英] convert multiple optional $_GET parameters to clean URLs

查看:65
本文介绍了将多个可选的$ _GET参数转换为清理URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html表单,其中包含多个元素,特别包括文本字段,选择下拉列表等。



我正在寻找的是,每当表单时提交,我希望URL地址栏中的表单获取参数更改为更多用户和搜索引擎友好的URL。



例如,提交后,我想要:



www.example.com/index.php?par1=val1&par2=val2&par3=val3&par4=&par5=val5



更改为:



www.example.com/val1/val2/val3/val5/



正如您在上面的示例中所看到的,如果参数值为NULL或等于特定值(例如此处为par4),我希望该值不会出现在结果友好URL中。



我怎么能实现这个目标?我想我应该使用apache mod_rewrite但我是mod_Rewrite的初学者,感谢你帮助我。



提前谢谢!

解决方案

如果您是Apache URL重写(mode_rewrite)的初学者,您只需要学习它。没有其他办法。请参阅本指南:

http://httpd.apache.org/docs /2.0/misc/rewriteguide.html [ ^ ]。



另外,为了一般理解,请参阅以下内容:http://en.wikipedia.org/wiki/Rewrite_engine [ ^ ]。



-SA


I have an html form that has multiple elements specially including text fields, select dropdowns,etc.

What I'm looking for, is that whenever the form is submitted, I want the form get parameters in the URL address bar to change to a more user & search engine friendly URL.

As an example, after submission, I want:

www.example.com/index.php?par1=val1&par2=val2&par3=val3&par4=&par5=val5

to change to:

www.example.com/val1/val2/val3/val5/

And as you can see in the above example,if a parameter value is NULL or equal to a specific value(e.g par4 here),I want the value not to appear in the result friendly url.

How can I achieve this?I think I should use apache mod_rewrite but I'm a beginner in mod_Rewrite and appreciate your helping me with this.

Thanks in advance!

解决方案

If you are a beginner with Apache URL rewrite (mode_rewrite), you just need to learn it. There is no other way. Please see this guide:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html[^].

See also, just in case, for general understanding: http://en.wikipedia.org/wiki/Rewrite_engine[^].

—SA


这篇关于将多个可选的$ _GET参数转换为清理URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆