As an experienced website operator familiar with AnQiCMS, I know that a friendly and logical URL structure is crucial for the website's search engine optimization (SEO) and user experience.AnQiCMS provides powerful flexibility in customizing pseudo-static URL structures, allowing us to design the most suitable link form for the website according to specific needs.
AnQiCMS中伪静态URL结构定制指南
Pseudo-static URL, as the name implies, is a technology that makes dynamic pages look like static pages.It not only enhances the user's understanding of URLs, but also enables search engine spiders to more effectively crawl and index page content, thereby improving the website's SEO performance.AnQiCMS in this aspect provides comprehensive support, whether through built-in modes for quick configuration or through customized rules for fine-tuning, it can meet the operation needs of various websites.
AnQiCMS伪静态功能概述
One of the core functions of AnQiCMS is pseudo-static and 301 redirect management.This enables us to optimize the website's URL structure, effectively manage traffic redirection after page adjustments, and avoid loss of SEO assets.The system design takes into account SEO-friendliness, and therefore provides a variety of configuration options in URL structure.Since version 2.0.0-alpha of AnQiCMS, the system has introduced the feature of custom URL rewrite rules, greatly enhancing flexibility.
内置伪静态规则选项
For convenient and quick deployment, AnQiCMS is built with four commonly used pseudo-static rules to meet the basic needs of different types of websites. These patterns usually cover the common URL habits of Chinese and English websites:
Digital mode: In this mode, the URLs of document details, document lists, single-page details, and document tag pages are mainly in{id}As a basis for generation, it is suitable for Chinese websites with high requirements for ID identification.
Model Naming Pattern: This pattern is more suitable for English websites, and it constructs URLs based on the model name of the content.
分类命名模式1与分类命名模式2:这两种模式提供了基于分类名称的URL结构,分别针对英文网站的习惯进行了优化。
For most websites, the built-in mode is sufficient to meet basic needs.But when we have more personalized and refined control requirements for the URL structure, custom mode becomes particularly important.
Custom configuration for rewrite rules
The custom rewrite mode of AnQiCMS is an advanced feature that allows us to define individual URL structures for the six main page types of the website. These page types include:
- Document details page (
archive) - Document list page (
category) - Model homepage (
archiveIndex) - Single Page (
page) - 标签列表页 (
tagIndex) - Tag detail page (
tag)
When configuring custom rules, each rule follows规则名===规则值format. For example,archive===/{module}-{id}.html就是一个为文档详情页定义的自定义规则。正确配置这些规则是确保网站正常访问和优化SEO的关键。
可用的URL变量
In custom pseudo-static rules, AnQiCMS provides a series of variables that can be flexibly combined to construct URL structures that meet specific needs. Understanding and proficiently using these variables is the foundation for advanced customization:
Data ID ({id}This variable represents the unique identifier for specific content, such as article, product, or a single page ID.It is usually used in the URL of the detail page to distinguish different content entries.
Data custom link name ({filename}):这是一个非常实用的变量,允许我们为单个文档、单页面或标签自定义一个短而描述性的链接别名。In the document, category, tag, and single page editing interfaces, there will be an option for 'Custom URL'.{filename}If so, the system will prioritize using the alias we have set.If not manually filled in, the system will automatically generate a pinyin alias based on the title.It should be noted that the custom link name must ensure the uniqueness across the entire site, and if it is duplicated, the system will automatically add random numbers to ensure its uniqueness.It can only contain letters, numbers, and underscores, and cannot contain spaces.
Category custom link name ({catname}): with{filename}similar, this variable is used specifically for document classification. We can set a custom alias for the category in the category editing page and through{catname}The variable is used in the URL. It also needs to ensure uniqueness throughout the site, and only supports letters, numbers, and underscores.
Category ID ({catid}This variable represents the unique ID of the content category. It is often used in the URL of document list pages or category detail pages to identify a specific category.
Model table name ({module}This variable indicates the table name in the database for the content model (such as article model, product model, etc.) or the URL alias set during the background configuration.It helps to reflect the type of content in the URL.
Page number (){page}): This variable will display the current page number when pagination is present. In use{page}There is an important syntax rule when defining a variable, that is, it must be placed within parentheses, for example(-{page})This ensures that there is no extra pagination information in the URL when there is no pagination or on the first page.
Configuration Examples and Warnings
Let us understand the combination application of these variables through a specific example:
Suppose we want the URL format of the document detail page to be/article-123.html, and the document list page to be/list-news(-2).htmlwhere,newsIs the category alias,2It is the page number. We can configure it like this:
archive===/{module}-{id}.html
category===/{catname}(-{page}).html
archiveIndex===/{module}.html
page===/{filename}.html
tagIndex===/tags(-{page})
tag===/tag-{id}(-{page})
In this example:
archive===/{module}-{id}.html: The document URL will be generated as similar to:/article-123.htmlin the form of,articleIs the model alias,123It is the document ID.category===/{catname}(-{page}).html: If the category alias is:news, then the URL of the first page of the category list may be:/news.htmlSecond page/news-2.html.
When configuring custom rewrite rules, be sure to pay attention to the following points:
- Correctness of the rulesAny syntax error can cause the page to become inaccessible, so careful testing should be performed after modification.
- Reasonable use of variables:Select the variable that best describes the page content and keep the URL concise.
- Uniqueness guaranteed:For
{filename}and{catname}, Ensure it is unique when set in the background; otherwise, the system will automatically append numbers. - Nginx/Apache Configuration:The activation of the pseudo-static rule still requires server-side Nginx or Apache configuration to work with it, ensuring that the request can be routed correctly to AnQiCMS for processing.In the AnQiCMS documentation, configuration examples for reverse proxy of Nginx and Apache are provided, which are the necessary prerequisites for the pseudo-static rules to work normally.
By carefully designing and configuring the pseudo-static URL structure, we can not only provide users with clear and memorable links, but also help the website gain better visibility and ranking in search engines, thereby achieving the goals of content marketing and traffic growth.AnQiCMS provides this capability, which is an indispensable tool for website operators in English.
Common Questions (FAQ)
1. I have configured custom rewrite rules, but the website page shows a 404 error, how should I troubleshoot it?Firstly, please check if the custom pseudo-static rule syntax you set in the AnQiCMS backend is correct, especially like{page}Does such a variable wrap correctly in parentheses.Ensure that your server configuration file (Nginx or Apache) has also been updated accordingly and restarted to correctly parse the new URL structure and forward it to AnQiCMS processing.You can refer to the AnQiCMS help document for the part about Nginx or Apache pseudo-static settings for verification.Finally, if your page content itself has a 'Custom URL' field, please confirm that its value is unique and conforms to the specifications.
2. Can I use Chinese in custom rewrite URLs?It is not allowed. Although some custom URLs of AnQiCMS (such as documents, categories' "custom URL" field) will automatically convert Chinese titles to pinyin when not manually filled in, but in the variables of pseudo-static rules (such as{filename}/{catname}/{module})中,as well as the custom link name you manually enter, are strongly recommended and usually only support the use of English letters, numbers, and underscores.Using Chinese or other non-English characters may cause URL parsing errors or compatibility issues, which is不利于SEO.
3. If I set{filename}or{catname}it not unique, how will AnQiCMS handle?AnQiCMS will try to ensure the uniqueness of all custom links within the website. If the system detects that you have set a custom URL for documents, categories, or tags (i.e.{filename}or{catname}The value) is duplicated with other existing URLs, it will automatically append a random number to the duplicated URL to ensure uniqueness.Although this can avoid conflicts, it is recommended to ensure that the custom URL is unique when setting it up to maintain the conciseness and predictability of the URL.