PHP Framework-why PHP project portal files are placed in subdirectories

Source: Internet
Author: User
Tags php framework
Recently saw some of the framework PHP portal files are placed in subdirectories, such as the TP5 framework portal file in the public directory of the package, as well as the new Fingers CMS Portal file is not in the root directory of the program, but in a subdirectory of the file, so that the domain name is bound to the program subdirectory, I wonder why the entry file is placed in the program subdirectory, what is the benefit of doing so, and this seems to be a trend, seeking science!

Reply content:

Recently saw some of the framework PHP portal files are placed in subdirectories, such as the TP5 framework portal file in the public directory of the package, as well as the new Fingers CMS Portal file is not in the root directory of the program, but in a subdirectory of the file, so that the domain name is bound to the program subdirectory, I wonder why the entry file is placed in the program subdirectory, what is the benefit of doing so, and this seems to be a trend, seeking science!

These frameworks are generally single-entry (index.php), and in order to implement a single entry, rewrite orientation is required, but there is a problem: How to handle static resource files (images, CSS,JS, etc.).
The most common and simplest method is implemented by the server program to determine whether the access file exists before overriding it, which requires only one or two lines of code to solve the problem. But after doing so, if the resource files and code files in the same directory, it will still break the uniqueness of the portal (because the program files are also checked to exist, and finally directly access to the program files), all of these frameworks invariably separate the resource files and program files, placed in different folders. On the whole, that is why the portal is in the sub-directory.

Security considerations, exposing only the public part is enough.

Such a framework may also need to be used in conjunction with the rewrite of the Web server to redirect all requests to the router portal of the framework

So the path of the URL that the end user sees is a meaningful natural language phrase, not a pid=1234&sort=date

  • 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.