PHP how to implement http://x.php /? Id = 1 or even id = all save

Source: Internet
Author: User
Do not require x. phpx. php? Is id1 called like this? Do you have this class can be implemented mainly for pseudo static usually not need http://x.php/x.php? Id = 1?
Is there any class that can be implemented?

Mainly for pseudo-static

Reply content:

Usually not need http://x.php/x.php? Id = 1?
Is there any class that can be implemented?

Mainly for pseudo-static

As long as there is "? "It is not pseudo-static if it exists in the URL. Because? The following are all obvious parameters.

If what you need is "/? 1 "this way, use$_SERVER['QUERY_STRING']To obtain? The following part is enough.

If you need "/1" (pseudo-static), you need to use. htaccess for rewrite, and then take$_SERVER['REQUEST_URI']And then proceed.

You can study php pathinfo.

If the owner is unwilling to study system functions or variables, we recommend that you refer to supesite or uchome. in earlier versions, the former prevents the server from supporting Rewrite, so it is similar /? View-space-id-1234.html processing. Use a program to perform operations similar to rewrite. Uchome also has a similar approach, but he has a little more that can directly access http://www.com /? 1234, representing http://www.com/view-space-uid-1234.ht...you can directly obtain the authentication code.
But if you want to go deep... Black and black. It is better to know more about the $ _ SERVER variable. Of course, the $ _ SERVER variable under various servers is not necessarily the same. More tests are required.

The address is pseudo-static.

$ String = "http://x.php /? Id = 1 "; $ string = str_replace ("? Id = "," ", $ string); echo $ string; // at this time, $ string = http://x.php/1#//if you want to replace the primary node, use preg_replace1_preg_replace_callbackto replace it.

After the actual address is pseudo-static on the page, the address is overwritten with APACHE, nginx, or IIS.

Use nginx as an example:
Address override after http://x.php/1 should be:

rewrite ^(.*)/x\.php/(.*)\.html$ $1/x.php?id=$2 last;

In this way, the effect you need is basically achieved.

You can use PJAX technology. PJAX is an encapsulation of AJAX + pushState.
The basic idea of PJAX is that the user clicks a link, updates the page changes through ajax, and then uses the HTML5 pushState to modify the URL address of the browser, this effectively prevents the whole page from being reloaded. If the browser does not support two new APIs or JS of history, this link can only jump to and refresh the entire page. Unlike the traditional ajax design, ajax usually obtains JSON data from the background and is parsed and rendered by the front-end. PJAX requests an HTML Fragment Generated on the server.
Http://qianduannotes.duapp.com/demo/PJAX/index.html is a demo, you click the next page to see the URL changes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.