1. Cause of the problem
When we add a path to the page, for example:
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/style.css">
If we find that the style is not loaded in the page table, it may be that the path is set incorrectly or is inaccessible. This may be caused by the "__PUBLIC__" alias not being set correctly in the ThinkPHP framework.
The path alias "__PUBLIC__" refers to the application's public folder path, which is located in the root directory of the application. If this path alias is not set correctly, the style sheet may not be accessible. Let's explore how to correctly set the alias for the "__PUBLIC__" path.
2. Solution
When setting the path alias "__PUBLIC__", you need to consider three aspects: the location of the application on the server and the configuration of the URL address. , Configuration of application file path.
The location of the application on the server
The root directory of the application should be located in the document root directory of the web server to ensure that all files can be accessed.
Configuration of URL address
Through the URL address, you can access various parts of the application. Therefore, the URL address needs to be configured correctly to ensure correct access of the path alias. The application's config.php file is the primary location for URL configuration in the ThinkPHP framework. You can configure the URL in config.php:
'URL_MODEL' => 2, 'URL_HTML_SUFFIX' => '.html', 'URL_CASE_INSENSITIVE' => true, 'URL_PATHINFO_FETCH' => 'ORIG_PATH_INFO,REDIRECT_PATH_INFO,REDIRECT_URL' 'URL_ROUTER_ON' => true,
For the meaning of each configuration item, you can check the official documentation of the ThinkPHP framework.
Configuration of application file paths
The path aliases of each file in the application need to be configured correctly. For example, the path alias "__PUBLIC__" generally points to the "/public" folder, while the path alias "__ROOT__" points to the root directory of the application. If these path aliases are not configured correctly, the file will become inaccessible.
The above is the detailed content of How to solve the problem that thinkphp cannot access the added path. For more information, please follow other related articles on the PHP Chinese website!

The article discusses ThinkPHP's built-in testing framework, highlighting its key features like unit and integration testing, and how it enhances application reliability through early bug detection and improved code quality.

Article discusses using ThinkPHP for real-time stock market data feeds, focusing on setup, data accuracy, optimization, and security measures.

The article discusses key considerations for using ThinkPHP in serverless architectures, focusing on performance optimization, stateless design, and security. It highlights benefits like cost efficiency and scalability, but also addresses challenges

The article discusses implementing service discovery and load balancing in ThinkPHP microservices, focusing on setup, best practices, integration methods, and recommended tools.[159 characters]

ThinkPHP's IoC container offers advanced features like lazy loading, contextual binding, and method injection for efficient dependency management in PHP apps.Character count: 159

The article discusses using ThinkPHP to build real-time collaboration tools, focusing on setup, WebSocket integration, and security best practices.

ThinkPHP benefits SaaS apps with its lightweight design, MVC architecture, and extensibility. It enhances scalability, speeds development, and improves security through various features.

The article outlines building a distributed task queue system using ThinkPHP and RabbitMQ, focusing on installation, configuration, task management, and scalability. Key issues include ensuring high availability, avoiding common pitfalls like imprope


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools