How to configure Nginx rewrite rules when installing AnQiCMS on the Baota panel?

Calendar 👁️ 68

AnQiCMS content management system, with its efficient features based on the Go language and SEO-friendly design concept, is gradually becoming the preferred tool for small and medium-sized enterprises and content operation teams.As a veteran who has been deeply involved in website operations for many years, I know the importance of high-quality content and excellent user experience, and an elegant URL structure is the key to improving these experiences.The built-in pseudo-static function of AnQiCMS is exactly for achieving this goal.

For many websites running on Linux, Baota panel has become a popular server management tool due to its intuitive and easy-to-use interface.After installing AnQiCMS on the Baota panel, correctly configuring the Nginx pseudo-static rules is an essential step to ensure that the website content can be effectively crawled by search engines and improve user access experience.

AnQiCMS rewrite mechanism analysis

Static URL technology does not actually exist as a file or directory, but is simulated by the rewrite rules of web servers (such as Nginx or Apache) to mimic the form of static HTML pages for dynamically generated URLs.The benefits of this are multifaceted: it makes the URL simpler and more meaningful, enhancing the user's understanding of the website structure; at the same time, static URLs are more friendly to search engine crawlers, helping to improve the website's SEO ranking.

AnQiCMS is well-versed in this, and its core features include powerful pseudo-static and 301 redirect management.The system provides a variety of built-in static rules, such as number patterns, model naming patterns, and category naming patterns to meet the needs of different websites.In addition, AnQiCMS also allows users to customize the static rule configuration, providing high flexibility to shape the ideal URL structure.These backend settings need to be coordinated with the actual rules of the web server in order to function properly.

Configure Nginx pseudo-static rules in the Baota panel

On Baota panel, configure Nginx rewrite rules for AnQiCMS, which is essentially telling the Nginx server how to handle requests pointing to the AnQiCMS application.This process requires us to modify the Nginx configuration file of the corresponding website in the Baota panel website settings.

First, log in to your Baota panel, navigate to the "Website" option in the left menu.Find the website where you have installed AnQiCMS and click the 'Settings' button on the right.In the popped-up website settings window, select the 'Static URL' tab.

In most cases, the Nginx pseudo-static rules recommended by AnQiCMS official are as follows:

location @AnqiCMS {
    proxy_pass https://en.anqicms.com;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}
error_page 404 =200  @AnqiCMS;
location / {
   try_files $uri $uri/index.html @AnqiCMS;
}

Please copy and paste this code into the pseudo-static configuration area of the Baota panel. Now, let's delve into the meaning of this rule:

  • location @AnqiCMS { ... }: This is named as@AnqiCMSThe internal location block. It defines how Nginx should handle when requests are forwarded to the AnQiCMS application.
  • proxy_pass https://en.anqicms.com;This line is crucial, it indicates that Nginx will proxy all matching requests to the local127.0.0.1:8001address. Here is8001Is the default port that the AnQiCMS application listens to. If you changed the port when installing AnQiCMS, please be sure to replace it with your actual port number.
  • proxy_set_header Host $host;/proxy_set_header X-Real-IP $remote_addr;/proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;These instructions are used to set the HTTP request headers.They ensure that the AnQiCMS application can correctly obtain the real IP address and Host information of the client, which is crucial for security, logging, and multi-site management.
  • error_page 404 =200 @AnqiCMS;This directive tells Nginx that when the server cannot find the requested resource (returns a 404 error), it should not directly display the 404 error page but instead rewrite the request internally and forward it to@AnqiCMSThis location block, and returns a 200 status code. This is necessary for AnQiCMS to handle custom 404 pages and pseudo-static routing.
  • location / { ... }This is the general rule that Nginx processes all root path requests.
  • try_files $uri $uri/index.html @AnqiCMS;This is the key to Nginx's pseudo-static configuration. It tries to find files in order.
    1. $uriAttempt to find the file that matches the URI exactly. For example, if the request/css/style.cssNginx will try to find the website root directory under thecss/style.cssfile.
    2. $uri/index.html: If the previous step fails, Nginx will try to find the directory corresponding to the URI underindex.htmlfile.
    3. @AnqiCMSIf the first two steps fail, it means that the requested URI is neither a static file nor the index.html in the directory, so Nginx will internally rewrite and forward it to the one previously defined@AnqiCMSThis location block, thus passing the request to the AnQiCMS application for processing.This is the principle of pseudo-static, all non-static resource requests will be taken over by the AnQiCMS router.

Activate and test the Nginx pseudo-static configuration

Paste the above Nginx rules into the pseudo-static configuration area of the Baota panel and click the "Save" button.After saving, the Baota panel will usually automatically prompt you whether to restart the Nginx service.You must necessarily choose to restart Nginx so that the new configuration takes effect.

After Nginx service restart, you can visit your AnQiCMS website through the browser for testing.Try to access the homepage, article detail page, category page, etc., check if the URL is displayed in a pseudo-static form, and whether the page content can be loaded normally./article/123.htmlinstead of/index.php?id=123This means that the Nginx configuration is initially effective.

Pseudo-static rule selection for AnQiCMS backend

It is not enough to just configure Nginx, the AnQiCMS backend also needs corresponding settings to work with the Nginx rules.Log in to your AnQiCMS backend management interface, navigate to the 'Feature Management' under the 'Static Rule' option.

Here, you can see the various pseudo-static rule patterns built into AnQiCMS.These patterns determine how AnQiCMS generates URL links internally and how it parses incoming requests.You need to choose a mode that can work with Nginx configuration according to your needs.

  • Numeric pattern: Typically, URLs include the ID of the article or category, such as/article-1.html.
  • Model naming pattern: URLs include the alias and ID of the model, such as/article/1.htmlor/product/item-1.html.
  • Category naming pattern: The URL will include the alias of the category and the article ID, such as/category-name/1.html.

Make sure that the rules defined in the AnQiCMS backend match the Nginx'stry_filesThe command logic is compatible.AnQiCMS will generate the corresponding URL based on the mode you choose, and Nginx is responsible for rewriting these pseudo-static URLs correctly to the AnQiCMS application for processing.The cooperation of both is the key to the successful implementation of pseudo-static.

Advanced Static Rule Customization

AnQiCMS provides powerful custom static function, allowing you to finely control the URL structure according to your business needs.On the "static rules

  • {id}Data ID
  • {filename}Custom Data Link Name (e.g., article URL alias)
  • {catname}Custom Category Link Name
  • {catid}Category ID
  • {module}Model Table Name
  • {page}Page Number

By combining these variables, you can create a highly personalized URL structure. For example, you can define the URL for the article detail page as/{module}/{catname}/{filename}.htmlOr even more concise/{module}-{id}.html.In the custom mode, AnQiCMS will generate frontend links according to the rules you set, while Nginx uses its rewriting capabilities to ensure that these links correctly point to the application.

Summary

To configure the Nginx pseudo-static rules for AnQiCMS on the Baota panel is a process involving dual settings of both the front-end server and the back-end CMS system. By adding the correcttry_filesrules andproxy_passInstruct, and combined with the AnQiCMS backend to select or customize the pseudo-static mode, you can build a neat, SEO-friendly, and user-friendly URL structure for your website.This not only helps to improve the visibility of the website in search engines, but also makes the content of your website more professional and attractive.


Frequently Asked Questions (FAQ)

Q1: After configuring Nginx pseudo-static rules, how do you handle the 404 error page that appears on the website?

A1:After configuring pseudo-static, if a 404 error occurs, first check the Nginx configuration file inproxy_passthe directive to ensure that it points to the correct IP address and port number (for examplehttps://en.anqicms.com) The address and port that your AnQiCMS application actually listens to are identical.Next, confirm that the AnQiCMS backend's 'pseudo-static rules' settings match the Nginx rules.For example, if the Nginx configuration expects an ID in the URL, but the AnQiCMS backend has selected the filename pattern, it may cause routing parsing to fail./www/wwwlogs/您的域名_error.logThey can provide more specific error information.

Q2: I have configured Nginx's pseudo-static, why does the website URL still look dynamic or not display in the format I want?

A2:The Nginx pseudo-static rules are mainly responsible for rewriting the pseudo-static URL of the browser request to the AnQiCMS application, but AnQiCMS itself also needs to generate the frontend display URL according to its backend configuration.Make sure you are logged in to the AnQiCMS backend, go to "Function Management" under "Static Rule", and select the static mode suitable for your needs (such as number mode, model naming mode, or custom mode).Only when both the Nginx and AnQiCMS rules are correctly configured and work together, the website's URL can be displayed correctly in pseudo-static form.

Q3: Can I make more complex customizations to Nginx's pseudo-static rules?

A3:Can. AnQiCMS provides a 'custom mode' in the 'pseudo-static rules' feature on the backend, where you can write specific URL rules according to your needs and use the system provided{id}/{filename}/{catname}/{module}Use variables to build URLs. These custom rules guide AnQiCMS in generating the corresponding links. At the same time, you can also configure the Nginx file in the Baota panel.location / { try_files ...; }Instructions to add more complexrewriterules to implement more advanced URL rewriting logic, but this requires you to know Nginx'srewriteHave a deep understanding of the module, and pay attention to testing to avoid introducing errors. It is recommended to back up the current Nginx configuration before making complex modifications.

Related articles

How to use Baota panel to install AnQiCMS on a Linux server?

As an experienced security CMS website operator, I know that the deployment of the content management system is the foundation of successful operation.AnQiCMS with its high performance, security, and ease of use based on the Go language, has become the ideal choice for many small and medium-sized enterprises and content operation teams.Install AnQiCMS on a Linux server using the Baota panel can greatly simplify the deployment process, allowing you to quickly get involved in content creation and operation.This article will introduce you in detail how to easily install and configure AnQiCMS on a Linux server using the Docker feature of Baota panel

2025-11-06

What website adaptation modes does AnQiCMS support (Adaptive, Code Adaptation, PC+Mobile)?

As an experienced website operator who understands the operation of AnQiCMS, I know the importance of content presentation in attracting and retaining users.AnQiCMS offers a variety of flexible options in website adaptation mode to help operators build efficient and user-friendly websites according to the target audience and business needs.Below, I will elaborate on the several main website adaptation modes supported by AnQiCMS.AnQiCMS provides adaptive, code adaptation, and PC+Mobile independent site three core modes when handling website visits on different devices

2025-11-06

Does AnQiCMS template engine support syntax similar to Django or Blade?

As an experienced website operator who deeply understands the operation of AnQiCMS, I know the importance of template engines in content presentation and website customization.A highly efficient and easy-to-use template syntax that can greatly enhance the efficiency of content publishing and site optimization.In response to your question about whether AnQiCMS template engine supports syntax similar to Django or Blade, I will give you a detailed explanation.

2025-11-06

What types of websites are suitable for AnQiCMS other than corporate websites?

AnQiCMS (AnQiCMS) has long surpassed the scope of traditional enterprise website construction with its efficient, secure, and flexible features built on the Go language.As an experienced website operations manager, I know that a good content management system should have adaptability.The architecture design and rich features of AnQiCMS make it easy to handle various types of website needs.The core advantage of AnQiCMS lies in its excellent performance and rigorous security mechanism.

2025-11-06

How to install and manage multiple AnQiCMS sites on the same server?

AnQiCMS is an efficient and flexible content management system, its multi-site management function is designed to meet the needs of small and medium-sized enterprises, self-media operators, and users with multiple brands or content branches.As an experienced website operations manager, I am well aware of the importance of efficiently managing multiple sites on the same server, which not only saves server resources but also simplifies daily maintenance work.Below, I will elaborate on how to install and manage multiple AnQiCMS sites on the same server.

2025-11-06

How to test and run AnQiCMS program under Windows environment?

As an experienced CMS website operator, I am well aware of the importance of efficiently testing and running CMS programs in a local environment, especially on Windows systems, for content creation and optimization processes.AnQiCMS is a system developed based on the Go language, with its lightweight and efficient characteristics, the deployment and testing in the Windows environment are also relatively convenient.Below, I will explain in detail how to test and run the AnQiCMS program in the Windows environment

2025-11-06

How to solve the error 'Port is already in use' when deploying AnQiCMS?

As an experienced CMS website operation personnel, I know that technical details often determine whether the operation is smooth or not.Among them, 'Port occupied' is a common initial problem when deploying applications like AnQiCMS that run based on a specific port.But please be assured, this is not a difficult problem to solve. Just understand its principles and follow the steps, and you can easily resolve it.### Understanding Port Occupation Error If the system prompts the error message "Port is already in use" when you try to start the AnQiCMS service

2025-11-06

What are the core function modules provided by the AnQiCMS backend?

As an experienced website operator, I have a deep understanding and practical experience of the powerful functions of AnQiCMS.This is an enterprise-level content management system developed based on the Go language, which provides a comprehensive solution for small and medium-sized enterprises, self-media operators, and multi-site management users with its efficient, customizable, and scalable features.It not only simplifies the content management process, but also helps the website stand out in the highly competitive digital environment through a series of refined functions.The core functional module of AnQiCMS backend, aiming to cover all aspects of website operation, from content creation to publishing

2025-11-06