After the project was changed to Linux, were the $_GET[] input parameters urlencoded by default? ? ?

WBOY
Release: 2023-03-01 17:40:02
Original
1316 people have browsed it

It turns out

Server: Win2003 + IIS runs normally without problems
Local: Win10 + apache and Win10 + nginx runs normally without problems

Now

The project recently replaced Alibaba Cloud CentOS7.2 and nginx1.10.2; a problem occurred.

Specific questions (the project is written in ThinkPHP3.2.3)

There is a Form form in the page for search, and the get data for search. After clicking the button, the following URL is formed

<code>/index.php/User/index.html?key=刘</code>
Copy after login
Copy after login

I use I('key') (TP-encapsulated method of obtaining input variables similar to $_GET['key']) in the controller to obtain this keyword, and then query and paginate; the page number link generates a URL similar to the following

<code>/index.php/User/index/key/刘/p/2.html</code>
Copy after login
Copy after login

When clicking the page number link above to turn the page:

  • No matter how you get the key locally or from the original server, the key is string "Liu"

  • But on the new server, the keyword obtained is string "%e5%88%98"

This resulted in all my original programs with this kind of search being ineffective and unable to turn pages.

Solutions I tried

  • I('key') uses urldecode when getting the data, but I found that I can only turn one page. If I do it again, the key will be urlencoded again. No matter how many times I turn it, it will be urlencoded infinitely

  • Since the url pattern cannot be modified, I gave up this method

Why?

Win+IIS Win+nginx is no problem. Why does this problem occur when using linux+nginx? Is this the fault of me, Linux, or nginx? Please advise.

We are very urgent to get the project back to normal, please help me with the answers

Reply content:

It turns out

Server: Win2003 + IIS runs normally without problems
Local: Win10 + apache and Win10 + nginx runs normally without problems

Now

The project recently replaced Alibaba Cloud CentOS7.2 and nginx1.10.2; a problem occurred.

Specific questions (the project is written in ThinkPHP3.2.3)

There is a Form form in the page for search, and the get data for search. After clicking the button, the following URL is formed

<code>/index.php/User/index.html?key=刘</code>
Copy after login
Copy after login

I use I('key') (TP-encapsulated method of obtaining input variables similar to $_GET['key']) in the controller to obtain this keyword, and then query and paginate; the page number link generates a URL similar to the following

<code>/index.php/User/index/key/刘/p/2.html</code>
Copy after login
Copy after login

When clicking the page number link above to turn the page:

  • No matter how you get the key locally or from the original server, the key is string "Liu"

  • But on the new server, the keyword obtained is string "%e5%88%98"

This resulted in all my original programs with this kind of search being ineffective and unable to turn pages.

Solutions I tried

  • I('key') uses urldecode when getting the data, but I found that I can only turn one page. If I do it again, the key will be urlencoded again. No matter how many times I turn it, it will be urlencoded infinitely

  • Since the url pattern cannot be modified, I gave up this method

Why?

Win+IIS Win+nginx is no problem. Why does this problem occur when using linux+nginx? Is this the fault of me, Linux, or nginx? Please advise.

We are very urgent to get the project back to normal, please help me with the answers

In the source code of TP paging, urlencode operation is performed when generating the URL

<code>private function url($page){
        return str_replace(urlencode('[PAGE]'), $page, $this->url);
    }</code>
Copy after login

Solution: You can pass the search parameter as the third parameter when instantiating the paging class. For details, please view the construction method of the Page class

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!