如何缩短URL查询参数? [英] How can I shorten the URL query paramters?

查看:113
本文介绍了如何缩短URL查询参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本正在生成一个很长的网址,就像下面的网址一样,我想知道如何通过算法或技术来缩短网址?

My script is generating a very long URL just like the one below and I wonder how this can be shorten with an algorithm or technique?

这是长网址: http://示例. com/script.php?param1 = value1& param2 = value2& param3 = value3& param4 = value4& param5 = value5

我想将其缩短为以下形式: http://example.com/script.php?p=430x2920

I want to shorten it to something like this: http://example.com/script.php?p=430x2920

如何在不将原始链接缓存到数据库的情况下做到这一点?

How can I do this with out caching the original link the database?

谢谢.

推荐答案

您始终可以只使用带有定界符的单个参数,然后将其拆分回代码中.

You could always just use a single param with a delimiter and then split it back out in code.

http://example.com/script.php?p=1x2x3x4x5

使用x或任何您想要的值而不是可能值的一部分(以分号表示).

with x or whatever you want that isn't part of the possible values as a delimeter.

这篇关于如何缩短URL查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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