Home  >  Article  >  Backend Development  >  How to encrypt url in php? It’s not particularly long.

How to encrypt url in php? It’s not particularly long.

WBOY
WBOYOriginal
2016-09-27 14:18:101238browse

How to encrypt url in php? It’s not particularly long

Reply content:

How to encrypt url in php? It’s not particularly long

urlencode, not encryption

urlencode

I don’t know how you want to encrypt, is it like this? This is encoded with urlencode. Of course, it only parses Chinese characters and some special characters, such as plus signs and the like
www.xmy365.com/search/apachesolr_search/%5B %E9%87%91%E9%BE%99%E4%B9%A1%E6%9E%9C%E4%B8%9A%5D%20%E7%94%98%E8%82%83%E9%9D %99%E5%AE%81%E7%BA%A2%E5%AF%8C%E5%A3%AB%2012%E4%B8%AA%E7%9B%92(%E7%BA%A62.3kg)

If you pass url as a parameter, it is recommended to use base64_encode for encoding. At the same time, replace the unsafe characters

<code>//处理为URL安全模式
function reflowURLSafeBase64($str){
    $str=str_replace("/","_",$str);
    $str=str_replace("+","-",$str);
    return $str;
}

//反解
function reflowNormalBase64($str){
    $str=str_replace("_","/",$str);
    $str=str_replace("-","+",$str);
    return $str;
}</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn