Use php to briefly implement the SearchEngineFriendly URL

Source: Internet
Author: User
For example, if I use a virtual host and want to optimize the url, but I don't have the server permission, I can start with PATH_INFO to visit ingress.

Last time I wrote the Search Engine Friendly URL design-I am tossing on this matter, to implement this http://www.myhost.com/foo.php? A = A & B = B & c = C-> http://www.myhost.com/foo.php/a/a/ B/B /c/c/c's url, and there are also different measures in the upper part.

For example, if I use a virtual host and want to optimize the url, but I do not have the server permission, I can start with PATH_INFO.

Visit the ghost and use php to parse it at this time:

Plain textphp:

If (! Empty ($ _ SERVER ['path _ info']) {
$ Paths = explode ('/', substr ($ _ SERVER ['path _ info'], 1 ));
For ($ I = 0, $ cnt = count ($ paths); $ I <$ cnt; $ I)
$ _ GET [$ paths [$ I] = @ (string) $ paths [$ I];
}

In this way, we can simply convert PATH_INFO into a global $ _ GET array, which has another benefit.

Http://www.myhost.com/foo.php? A = A & B = B & c = C
Http://www.myhost.com/foo.php/a/A/ B/B /c/C
The above url can be visited at the same time, ensuring versatility

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.