search
HomePHP FrameworkThinkPHPHow to solve the problem that thinkphp cannot access the added path

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.

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

  1. 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:

&#39;URL_MODEL&#39; => 2,
&#39;URL_HTML_SUFFIX&#39; => &#39;.html&#39;,
&#39;URL_CASE_INSENSITIVE&#39; => true,
&#39;URL_PATHINFO_FETCH&#39; => &#39;ORIG_PATH_INFO,REDIRECT_PATH_INFO,REDIRECT_URL&#39;
&#39;URL_ROUTER_ON&#39; => true,

For the meaning of each configuration item, you can check the official documentation of the ThinkPHP framework.

  1. 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!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
What Are the Key Features of ThinkPHP's Built-in Testing Framework?What Are the Key Features of ThinkPHP's Built-in Testing Framework?Mar 18, 2025 pm 05:01 PM

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.

How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?Mar 18, 2025 pm 04:57 PM

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

What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?Mar 18, 2025 pm 04:54 PM

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

How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?Mar 18, 2025 pm 04:51 PM

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

What Are the Advanced Features of ThinkPHP's Dependency Injection Container?What Are the Advanced Features of ThinkPHP's Dependency Injection Container?Mar 18, 2025 pm 04:50 PM

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

How to Use ThinkPHP for Building Real-Time Collaboration Tools?How to Use ThinkPHP for Building Real-Time Collaboration Tools?Mar 18, 2025 pm 04:49 PM

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

What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?Mar 18, 2025 pm 04:46 PM

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

How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?Mar 18, 2025 pm 04:45 PM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

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

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools