Best Practices and Recommendations for WordPress Permalinks

WordPress is a powerful CMS, meaning that its posts, pages, and archives are all dynamically generated from a database. While a site can have thousands of pages, they all share a single entry point: the “index.php” file in the root directory. When we visit a page, WordPress uses URL parameters to fetch the correct data and display the corresponding content to the user.

Why Use Search Engine Friendly (SEF) URLs?

By default, WordPress post URLs look like https://example.com/index.php?p=123, where “123” is the post ID. This “plain” structure is not very user-friendly or optimal for SEO. To make URLs cleaner and more meaningful, most users choose to remove “index.php” and use a more descriptive structure.

How to Remove index.php?

Removing “index.php” from your URLs is simple. Go to Settings > Permalinks in your WordPress dashboard and choose any option other than “Plain.” After saving your changes, you have enabled what is often called “pseudo-static” or “pretty” permalinks.

For better SEO, we recommend the Post name structure. If you want to avoid non-ASCII characters in your URLs, consider using a plugin like Wenprise Pinyin Slug to automatically convert Chinese titles to pinyin or English.

Server Configuration for Pretty Permalinks

After changing permalink settings, you might find that while your homepage works, other pages return 404 errors. This happens because your server needs specific URL rewriting rules to handle these cleaner URLs.

Nginx Rewrite Rules

For Nginx servers, you need to add a simple rewrite rule to your virtual host configuration and reload Nginx (nginx -s reload):

location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
}

Apache Rewrite Rules

Most Apache servers support .htaccess files. When you save your permalink settings, WordPress usually attempts to update your .htaccess file automatically. If it can’t, it will provide the code for you to manually add to the file.

Setting up descriptive permalinks is an essential step for any WordPress site. It improves both user experience and search engine visibility, making it a foundational best practice for site owners.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *