Use custom permalinks

January 22, 2012     0 comments

Choosing your permalink structure

In the Settings > Permalinks panel (Options > Permalinks before WordPress 2.5), you can choose one of the "common" structures or enter your own in the "Custom structure" field using the structure tags.

Please note: You never, ever put your site url in the permalinks slot. You must use one of the structure tags, or a combination of tags only.

To activate PATHINFO permalinks, start your permalink structure with index.php/.

Structure Tags

Please note:
You never, ever put your site url in the permalinks slot. You must use one of the structure tags, or a combination of tags only. 

You can use these tags to customize your "Pretty" or "Almost Pretty" permalinks. A few hints:

Make sure to end your structure with either %post_id% or %postname% (e.g. /%year%/%monthnum%/%day%/%postname%/) so that each permalink points to an individual post.
 %year%
The year of the post, four digits, for example 2004
 %monthnum%
Month of the year, for example 05
 %day%
Day of the month, for example 28
 %hour%
Hour of the day, for example 15
 %minute%
Minute of the hour, for example 43
 %second%
Second of the minute, for example 33
 %post_id%
The unique ID # of the post, for example 423
 %postname%
A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI.
 %category%
A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI.
 %author%
A sanitized version of the author name.

Creating and editing (.htaccess)

If you do not already have a .htaccess file, create one. If you have shell or ssh access to the server, a simple touch .htaccess command will create the file. If you are using FTP to transfer files, create a file on your local computer, call it 1.htaccess, upload it to the root of your WordPress folder, and then rename it to .htaccess.

You can edit the .htaccess file by FTP, shell, or (possibly) your host's control panel.

The following permalink rewrite code should be included in your .htaccess file (since WordPress 3.0):

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If your .htaccess file contains errors that bring down your site ("Internal Server Error (500)"), you will need to use FTP or your host's control panel to delete the rogue .htaccess file.

How helpful was this article to you?

FraudLabs Pro Secured Seal