Using Permalinks
Permalinks are the permanent URLs to your individual weblog posts, as well as categories and other lists of weblog postings. A permalink is what another weblogger will use to link to your article (or section), or how you might send a link to your story in an e-mail message. The URL to each post should be permanent, and never change — hence permalink.Permalink Types
There are three basic types of WordPress permalinks:Default: "Ugly"
The default looks likehttp://example.com/?p=Nwhere N is the Post ID number. It works on all server environments, but it doesn't look as nice as some of the other options.
mod_rewrite: "Pretty Permalinks"
Using mod_rewrite or lighttpd you can produce much nicer permalinks (see Pretty Permalinks). There are many different formats, but the most common, and most versatile looks likehttp://example.com/category/post-name/ or http://example.com/year/month/day/post-nameSome people eliminate some or all of the date elements (day, month, year) to have a shorter permalink format.
Pretty permalinks are available under
- Apache web server with the mod_rewrite module
- Microsoft IIS 7+ web server with the URL Rewrite 1.1+ module and PHP 5 running as FastCGI
- Microsoft IIS 6+ using ASAPI_Rewrite
- Lighttpd using a 404 handler or mod_rewrite (see See Also)
PATHINFO: "Almost Pretty"
PATHINFO permalinks look very much like mod_rewrite permalinks but for one exception: they have /index.php inserted before them, like so:http://example.com/index.php/yyyy/mm/dd/post-name/Otherwise, they are the same as the "pretty" mod_rewrite permalinks, and are similarly flexible. Anything that mod_rewrite permalinks can do, PATHINFO permalinks can do, with the help of that /index.php part.
There is a helpful plugin that displays the type of permalinks being used and detailed information on the internal rewrite rules used by WordPress.
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.
- %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
- %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 (see Using only %postname%). Starting Permalinks with %postname% is strongly not recommended for performance reasons..
- %post_id%
- The unique ID # of the post, for example 423
- %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. Starting Permalinks with %category% is strongly not recommended for performance reasons.
- %tag%
- A sanitized version of the tag name (tag slug field on New/Edit Tag panel). Starting Permalinks with %tag% is strongly not recommended for performance reasons
- %author%
- A sanitized version of the author name. Starting Permalinks with %author% is strongly not recommended for performance reasons
Using "Pretty" permalinks (IIS)
Permalinks without mod_rewrite
"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite. (If you are using Apache 2.0.54, on Windows, mod_rewrite may work, provided it is enabled in apache\conf\httpd.conf.)If you are using IIS 7 and have admin rights on your server, you can use Microsoft's URL Rewrite Module instead. Though not completely compatible with mod_rewrite, it does support WordPress's pretty permalinks. Once installed, open the web.config file in the WordPress folder and add the following rule to the system.webServer element
<rewrite> <rules> <rule name="Main Rule" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:0}" /> </rule> </rules> </rewrite>There's a full installation guide on the IIS site.
Download URL Rewrite Module 2.0
No comments:
Post a Comment