By default, WordPress uses post and page IDs in query strings in its URLs: On the Permalinks Settings screen (Figure 3-14), you can choose a custom URL structure (also known as clean URLs) if you have installed WordPress on one of the following servers:

• Apache or LiteSpeed, with the mod_rewrite module installed

• Microsoft IIS 7, with the URL Rewrite 1.1 module installed and PHP 5 running as FastCGI

• Microsoft IIS 6, using a 404 handler or a third-party rewrite module

• Lighttpd, using a 404 handler, mod_rewrite, or mod_magnet

If your server meets these conditions, you can switch to one of the other URL structures shown in Figure 3-14, or create your own using the available tags.

If your server uses .htaccess files to manage URL rewrites, WordPress will attempt to create or modify your .htaccess file when you save your Permalink options. If WordPress can't write to the file, you'll see the necessary rewrite rules displayed, and you'll be asked to edit the file yourself.

If you're using IIS 7, you'll need to add a rule to your web.config file after saving your Permalink structure. See for detailed information.

■ Security Tip: Once you've chosen your permalink structure, you should adjust your file permissions so that WordPress can no longer write to .htaccess. A number of common exploits involve altering your .htaccess file to redirect your visitors to other sites or append unwanted links to your WordPress pages. If changes to .htaccess are needed, they'll be displayed and you'll be asked to edit the file yourself.

If you are using any permalink structure other than the default for your posts, your pages will use pretty permalinks as well. The permalink structures use the page name (no matter what structure you've chosen for posts), and they form a directory-like chain based on the page hierarchy. Parent pages appear in the URL as if they were parent directories of static files. Table 3-1 shows a sample category structure and the resulting category archive URLs.

Table 3-1. Parent and child category permalinks.







Figure 3-14. The Permalinks Settings screen

You can change your permalink structure at any time. WordPress will store your previous permalink structure and will automatically redirect visitors from the old location to the new one using HTTP's 301 redirect protocol. However, it stores only one previous structure, so if you've changed it a few times, your visitors (and any search engines that indexed your site) might get lost.

■ Tip: URLs that contain a page's keywords tend to rank higher on most search engines. If you are interested in optimizing your site for search engine results, choose a permalink structure that includes the post name: Day and Name, Month and Name, or something like the Custom Structure shown in Figure 3-14. However, permalinks beginning with the post name or category can cause performance problems, which I will discuss in Chapter 11.

Was this article helpful?

0 0

Post a comment