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 static URL structures, allowing us to design the most suitable link format for the website according to specific needs.
Custom URL Structure Guide in AnQiCMS
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 the URL, but also allows search engine spiders to more effectively crawl and index page content, thereby improving the website's SEO performance.AnQiCMS provides comprehensive support in this aspect, 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 Static URL Function Overview
One of the core features of AnQiCMS is pseudo-static and 301 redirect management.This enables us to optimize the URL structure of the website, effectively manage the traffic redirection after page adjustments, and avoid the loss of SEO assets.The system design takes into account SEO-friendliness, and therefore provides multiple configuration options in the URL structure.Since the AnQiCMS v2.0.0-alpha version, the system has introduced the function of custom URL static rules, which greatly enhances flexibility.
Built-in Static URL Rule Options
For easy 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 stations:
The number mode: In this mode, the URLs of document details, document lists, single-page details, and document tag pages are mainly{id}Used as a basis for generation, suitable for Chinese websites with high requirements for ID identification.
Model naming pattern: This pattern is more suitable for English websites, as it constructs URLs based on the model name of the content.
Category naming pattern 1 and category naming pattern 2: These two patterns provide URL structures based on category names, optimized for the habits of Chinese and English websites.
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 pseudo-static rules
AnQiCMS's custom pseudo-static mode 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) - Tag list page (
tagIndex) - Tag detail page (
tag)
When configuring custom rules, each rule follows规则名===规则值format. For example,archive===/{module}-{id}.htmlThis is a custom rule defined for the document detail page. Properly configuring these rules is crucial for ensuring normal website access and optimizing SEO.
Available URL variables
In the custom static rule, AnQiCMS provides a series of variables that can be flexibly combined to build URL structures that meet specific needs. Understanding and skillfully using these variables is the foundation for advanced customization:
Data ID ({id}This variable represents the unique identifier for specific content, such as an article, product, or single page ID.It is usually used in the URL of the detail page to distinguish different content items.
Custom data link name ({filename}This is a very practical variable, allowing us to customize a short and descriptive link alias for a single document, single page, or tag.In the editing interface of documents, categories, tags, and single pages, there will always be an option for 'Custom URL'.If we fill in a custom URL and use in the pseudo-static rules{filename}Then the system will prioritize using the alias we 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 that it is unique throughout the entire site. 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.
Custom category link name ({catname}): And{filename}Similar, this variable is dedicated to document classification. We can set a custom link alias for the category on the category editing page and proceed through{catname}The variable is used in the URL. It also needs to ensure the uniqueness across the entire 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 document list pages or category detail pages in URLs to identify a specific category.
Model table name ({module}This variable represents the table name in the database of the model to which the content belongs (such as article model, product model, etc.), or the URL alias set during backend configuration.It helps to reflect the type of content in the URL.
Page number ({page}): When the page has pagination, this variable will display the current page number. When using{page}there is an important syntax rule, that is, it must be placed inside 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 precautions
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, the document list page is:/list-news(-2).htmlof whichnewsIs a category alias,2Is a 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: Will generate the document URL similar to/article-123.htmlin the form ofarticleIs a model alias,123Is the document ID.category===/{catname}(-{page}).html: If the category alias isnewsThe URL for the first page of the category list may be/news.htmlAnd the second page is/news-2.html.
When configuring custom pseudo-static rules, be sure to pay attention to the following points:
- The correctness of the rulesAny syntax error can cause the page to become inaccessible, so it should be tested carefully after modification.
- Reasonable use of variables.: Choose the variable that best describes the page content and keep the URL concise.
- Uniqueness guarantee: 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 pseudo-static rules still requires server-side Nginx or Apache configuration to cooperate, ensuring that requests can be correctly routed to AnQiCMS processing.In the AnQiCMS help documentation, examples of Nginx and Apache reverse proxy configurations are provided, which are necessary prerequisites for the pseudo-static rules to work properly.
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 win 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.
Frequently Asked Questions (FAQ)
1. I have configured custom rewrite rules, but the website page shows a 404 error, how should I troubleshoot?First, please check the syntax of the custom pseudo-static rules you have set in the AnQiCMS backend, especially like{page}Whether this variable is correctly enclosed in parentheses. Secondly, make sure that your server (Nginx or Apache) configuration file has also been updated accordingly and restarted to correctly parse the new URL structure and forward it to AnQiCMS for processing.You can refer to the AnQiCMS help document for the part related to Nginx or Apache pseudo-static settings and check it.Finally, if your page content itself has a "custom URL" field, please confirm that the value is unique and conforms to the specifications.
2. Can I use Chinese in custom static URLs?May not. Although some custom URLs of AnQiCMS (such as documents, the 'custom URL' field of categories) will automatically convert Chinese titles to pinyin if not manually filled in, but in the variables of pseudo-static rules (such as{filename}/{catname}/{module}In addition to the manually entered custom link name, it is strongly recommended and usually only supported to use letters, numbers, and underscores.Using Chinese or other non-English characters may cause URL parsing errors or compatibility issues, which is not conducive to SEO.
3. If I set{filename}or{catname}Unique, how will AnQiCMS handle it?AnQiCMS tries 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, that is{filename}or{catname}The value) is duplicated with other existing URLs, and it will automatically append a random number to the repeated URL to ensure uniqueness.Although this can avoid conflicts, but in order to maintain the simplicity and predictability of the URL, it is recommended that you try to ensure its uniqueness when setting a custom URL.