Php Study Notes: MVC entry design and pseudo-static

Source: Internet
Author: User
Original notes, reprinted must indicate the source and link for php to develop web programs. The entry design of the MVC mode is very critical. frequently-used open source programs such as wordpress and discuz have special entry design, in addition to the controller and action, the routing design is also important, because it is related to the beauty of the url and the friendliness of the search. Wordpress portal and pseudo

Original notes, reprinted must indicate the source and link for php to develop web programs. The entry design of the MVC mode is very critical. frequently-used open source programs such as wordpress and discuz have special entry design, in addition to the controller and action, the routing design is also important, because it is related to the beauty of the url and the friendliness of the search. Wordpress portal and pseudo

Original notes, reprinted with the source and link

The entry Design of MVC mode is very critical for php to develop web programs. frequently-used open-source programs such as wordpress and discuz have special entry design, except for controller and action, the routing design is also important, because it is related to the beauty of the url and the friendliness of the search.

Wordpress entry and pseudo-static

Take wordpress as an example, the http://it.liuhuafang.com/code/2982? , We can easily analyze the code is classification of alias, 2982 is the Article id; and The http://edu.xiguagg.com/2013-xigua-collage/ watermelon Institute link is also an article, using the article alias.

Users open the http://it.liuhuafang.com/code/2982, rewrite and routing Field Values for filtering. Wordpress selects several fields that can be used in routing, such as category, post_id, and post_name, and sets a permalink fixed connection to solidify the type of url display.

Wordpress has a rewrite function to handle a variety of front-end request judgment mechanisms that may be set to permalink, so that key information field values can be extracted through various URLs, such as http://edu.xiguagg.com/2013-xigua-collage, wordpress searches for 2013-xigua-collage from the post_name field in permalink settings, and then returns post_id. This way, you can call post_id to obtain information about the document content page.

Discuz entry design and pseudo-static

Discuz is a multi-entry file mode design. They control and guide portals, forum, group, and home independently, which brings about pseudo-static complexity, therefore, the official default pseudo-static rule is set to dynamic. Of course, this is different from the product requirements. wordpress is mostly used for personal blogs, and there are usually few access requests. discuz is used for discussion areas and there are many concurrent requests. Once the access volume increases, the cost is a big challenge, so discuz chose to sacrifice personalization.

Of course, many webmasters began to like concise web site, such as http://bbs.jiabao.org/baixing/1, this is the domain name + classification alias + post id directory pseudo static structure, if the site information is large, this structure makes the internal structure of the website flat and will make the search more friendly. However, this is against the idea of discuz routing system design.

When you open the link to the community, you will find that this is a post. In fact, the category of the Forum on the home page of your community has been clicked here. Why?

In pursuit of a flat directory, the url such as bbs.jiabao.org/baixing/2 may be the page of a forum or a post link. In this way, the portal cannot identify the route. How can this problem be solved?

On the one hand, I want to change the Post url to bbs.jiabao.org/baixing/2.html? It is different from the rewrite rules in the forum. If it is necessary to post URLs such as bbs.jiabao.org/baixing/222, or start to make a large number of digits for the thread id through SQL, the fid of a forum is never likely to conflict with the tid value of the post. Alternatively, you need to modify the program design and bind the rewrite rules of the forum and the post for uniqueness, the resolution entry does not identify the pagination url or Post url of the topic list.

Forum topic list page {Fid}, {page}
Forum topic Content Page {Tid}, {page}, {prevpage}

The ultimate solution should be like this: unify the previous entry of the topic link and the rewrite of the topic content and the route control to solve the clean url of the Forum homepage, and add auxiliary parameters such as page on the page, in this way, bbs.jiabao.org/baixing/2 is submitted from the browser to the server, htaccess identifies and directs to the dynamic Php entry file, and points to the post page. Therefore, the {fid}/t {tid}/{page}, {fid}/{page} post page, and topic link page must have an auxiliary parameter, otherwise, the fid tid performs strict uniqueness deduplication and searches for the fid tid. Of course, this will consume some performance.

Original article address: php Study Notes: MVC entry design and pseudo-static, thanks to the original author for sharing.

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.