WordPress permalink settings are a crucial part of website setup and SEO optimization. They determine the URL structure for posts, pages, and other content, directly impacting user experience, search engine indexing, and site professionalism. A clear, logical permalink structure is fundamental for site optimization.
How to Configure WordPress Permalinks
You can find the permalink settings in your WordPress admin dashboard under Settings → Permalinks.
WordPress offers several preset structures and also supports custom ones. Common recommended settings include:
- Post name:
/%postname%/– The most popular and SEO-friendly option, producing clean, readable URLs. - Numeric:
/%post_id%– Uses the post ID, creating short, unique URLs that never change. - Custom Structure: Combine various tags, e.g.,
/%category%/%postname%.html, to add category paths or file extensions like.html.
After selecting or defining your structure, click 'Save Changes'.
Understanding and Setting Up URL Rewriting (Pseudo-Static)
'Pseudo-static' refers to using server rewrite rules (e.g., for Nginx/Apache) to transform dynamic URLs (often containing ? and =) into formats that resemble static files (like .html). This retains the flexibility of a dynamic application while gaining the SEO and aesthetic benefits of static-looking URLs.
Adding a .html Suffix
Adding a .html suffix to your custom structure (e.g., /%postname%.html) is a common practice. It makes post links appear more like static pages, which some believe can be favorable for SEO in certain contexts, though it's not mandatory and is largely a matter of preference.
Important: Simply changing the permalink structure to end in .html in WordPress is not enough. You must also configure the corresponding rewrite rules on your server; otherwise, you will encounter 404 errors.
Server Rewrite Rule Configuration
Here are configuration methods for two common server environments.
Method 1: Using a Control Panel (e.g., BaoTa)
If you use a control panel like BaoTa, the process is straightforward:
- Log into your panel and navigate to the Websites management page.
- Click the Settings button for your site.
- In the settings panel, find and click the URL Rewrite (Pseudo-Static) option.
- From the dropdown menu, select wordpress.
- Click Save.
The panel will automatically configure the appropriate Nginx or Apache rewrite rules for your permalink structure.
Method 2: Manual Nginx Configuration
If you manage the server directly, add the following rules inside the server {} block of your site's Nginx configuration file:
location / {
try_files $uri $uri/ /index.php?$args;
}
# Optional: Ensure proper wp-admin access
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
The core of this rule is the try_files directive. It checks in order: if the requested file ($uri) exists → if the requested directory ($uri/) exists → if neither exists, it passes the request to WordPress's index.php with all arguments ($args). This ensures WordPress can correctly handle any permalink structure.
After configuration, restart or reload your Nginx service for the rules to take effect.
Summary and Best Practices
- Permalink Structure: Decide on and set your structure before launching your site. For new sites,
/%postname%/or/%post_id%are excellent choices. Changing permalinks after content is published will break existing links and requires proper 301 redirects. - Rewrite Rules: You must configure server rewrite rules whenever you use any permalink structure other than the default 'Plain' setting. Control panels greatly simplify this process.
- .html Suffix: Adding it is a preference, not a requirement, and does not decisively impact SEO. The key is maintaining a consistent, clean, and readable URL structure across your entire site.
By following these steps, you can correctly configure WordPress permalinks and URL rewriting, laying a solid technical foundation for your website.