• Using Permalinks

    作者:  • 2006 年 8 月 3 日 • 技术主义 • 暂无评论

    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 refer to your article (or section), or how you might send a link to your story in an e-mail message. Especially when they are used to link to individual postings, once a story is posted, the URL to it should be permanent, and never change. Hence the “perma” in the name.

    Structure Tags

    You can use these tags to customize your “Pretty” or “Almost Pretty” permalinks.

    %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. So “This Is A Great Post!” becomes “this-is-a-great-post” in the URI (see note below)
    %post_id% 
    The unique ID # of the post, for example 423
    %category% 
    A sanitized version of the category name. Nested sub-categories appear as nested directories in the URI.
    %author% 
    A sanitized version of the author name.

    These types of permalinks work on most systems without any problems, but there are still some conditions where problems occur.

    Note on using only %postname% 
    If you use postname as the only element in your permalinks to create a structure such as myblog.com/post-title, the rewrite rules may make it impossible to access pages such as your stylesheet (which has a similar format) or the wp-admin folder. It’s best to include some numeric data (e.g. the post ID or date) in the permalink to prevent this from happening. Additionally, WordPress v1.2.x requires the use of a date structure in order for some features, such as the calendar, to function properly. /%year%/%monthnum%/%day%/%postname%/ is always a good start.
    Note on using %category% 
    %category% does not work correctly with some implementations of mod_rewrite in Apache versions prior to 2. If you are using Apache 1 and experience problems with using %category, either do not use %category% in your permalink structure, or refer to Schlueterica’s plugin (http://isaacschlueter.com/plugins/i-made/lucky-13-rewrite/).
    Note on using %category% with multiple categories on a post 
    Where you assign multiple categories to a post, only 1 can show up in the permalink. This will be the lowest numbered category (see Manage Categories). The post will still be accessible through all the categories as normal.
    Properly terminating permalinks 
    It’s important to guarantee permalinks lead to individual posts within your custom URI, so make sure to end a virtual site structure with either %post_id% or %postname%
    /%year%/%monthnum%/%day%/%postname%/

    相关文章:

    关于

    生于古城長安,求學金陵,輾轉赴美深造,現漂泊於長安與北京。

    http://www.yenching.org