• Resolved maf5995r

    (@maf5995r)


    Hi. I’m trying to set my permalink structure to include the category name and postname. That is, I create a custom structure for permalinks in the Options>Permalinks panel as:

    /%category%/%postname%/

    I can display all posts in a category as https://www.example.com/category/website/ but when I try to access an individual post, the generated permalink does not include the %category% field. That is, the generated permalink is https://www.example.com//my-first-post/ for a post named “My First Post” in the “Website” category.

    [Note: WordPress does successfully generate permalinks when I set my structure to the default, date and name based, or numeric structures. I also tried setting the permalink structure to /archives/%category%/%postname%/ and the %category% field was dropped as well in that case. And, I’ve tried setting the custom prefix for your category URIs to ‘/taxonomy’.]

    [Note: I am running on Apache/1.3.27 and I understand that some have experienced problems using %category% in the permalink structure with Apache < 2.0, however https://www.ads-software.com/support/topic/41937 says it was not a problem. If this is my problem, is there a work around? I tried the Alternative Rewrite Rules workaround at https://boren.nu/archives/2004/10/08/alternative-rewrite-rules/ and experienced the same results. I am trying to make sense of the many postings.]

    I am using a non-hierarchical set of categories and each of my posts are only set to a single category.

    My .htaccess file was indeed set by WordPress:

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

    # END WordPress

    My configuration from phpinfo() is as follows:

    WordPress 2.0.4

    Apache Version Apache/1.3.27
    Apache Release 10327100
    Apache API Version 19990320

    Loaded Modules mod_webapp, mod_perl, mod_throttle, mod_php4, mod_frontpage, mod_ssl, mod_setenvif, mod_so, mod_unique_id, mod_usertrack, mod_headers, mod_expires, mod_cern_meta, mod_proxy, mod_digest, mod_auth_dbm, mod_auth_anon, mod_auth, mod_access, mod_rewrite, mod_alias, mod_userdir, mod_speling, mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_info, mod_status, mod_negotiation, mod_mime, mod_mime_magic, mod_log_config, mod_define, mod_env, mod_vhost_alias, http_core

    X-Powered-By PHP/4.2.2

    _SERVER[“SERVER_SOFTWARE”] Apache/1.3.27 (Unix) mod_perl/1.26 mod_throttle/3.1.2 PHP/4.2.2 FrontPage/4.0.4.3 mod_ssl/2.8.11 OpenSSL/0.9.6h

    GATEWAY_INTERFACE CGI/1.1
    SERVER_PROTOCOL HTTP/1.1

    MACHTYPE i386-redhat-linux-gnu

    Any pointers would be appreciated.

    Thanks,

    Mark – [email protected]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter maf5995r

    (@maf5995r)

    Digging a bit deeper…

    In template-function-links.php, at line 55-61:

    $category = ”;
    if ( strstr($permalink, ‘%category%’) ) {
    $cats = get_the_category($post->ID);
    $category = $cats[0]->category_nicename;
    if ( $parent=$cats[0]->category_parent )
    $category = get_category_parents($parent, FALSE, ‘/’, TRUE) . $category;
    }

    get_the_category indeed returns an array with a single element, but there is no set category_nicename (nor cat_ID nor cat_name) for that element.

    I’m wondering if this is the Apache problem or some other problem?

    Thanks,

    — Mark

    Thread Starter maf5995r

    (@maf5995r)

    I’ve created a work around for myself and I believe the problem is different than my initial suspicion.

    Ticket https://trac.www.ads-software.com/ticket/1199 appears to be the bug I’ve encountered.

    Here’s a summary:

    When I create a custom structure for permalinks in the Options>Permalinks panel as:

    /%category%/%postname%/

    the generated permalink using the get_permalink() function does not include the %category% field.

    For example, the incorrectly generated permalink is https://www.example.com//my-first-post/ for a post named “My First Post” in the “Website” category.

    Initially, I considered this might be a permalink generation with %category% and Apache 1.x problem. See https://www.ads-software.com/support/topic/90171.

    After working through some of the WordPress code, I believed it to be related to the WordPress 2.0+ caching problem mentioned elsewhere.
    See https://trac.www.ads-software.com/ticket/1199 and https://www.ads-software.com/support/topic/55472.

    However, disabling the cache through uncommenting define(‘DISABLE_CACHE’, true) in wp-settings.php did not fix my problem.
    Additionally, there is no wp-contents/cache directory in my installation and the webserver does not have write permission in my httpdocs directory.

    My configuration includes WordPress 2.0.4, Apache/1.3.27, PHP/4.2.2.

    My observations included that in template-function-links.php, at line 55-61:

    $category = ”;
    if ( strstr($permalink, ‘%category%’) ) {
    $cats = get_the_category($post->ID);
    $category = $cats[0]->category_nicename;
    if ( $parent=$cats[0]->category_parent )
    $category = get_category_parents($parent, FALSE, ‘/’, TRUE) . $category;
    }

    get_the_category indeed returns an array with a single element, but there is no set category_nicename (nor cat_ID nor cat_name) for that element.

    I added a few links of code to re-query the WordPress database when $category was not set as expected and this worked for me. Note, I know my installation contains a non-hierarchical set of categories and that only category is assigned to a single post and I did not work through a more general “fix”.

    $category = ”;
    if ( strstr($permalink, ‘%category%’) ) {
    $cats = get_the_category($post->ID);
    $category = $cats[0]->category_nicename;
    if (!isset($category)) {
    global $wpdb;
    $dogs = $wpdb->get_results(“SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id=$post->ID;”);
    $category_object = &get_category($dogs[0]->category_id);
    $category = $category_object->category_nicename;
    }
    if ( $parent=$cats[0]->category_parent )
    $category = get_category_parents($parent, FALSE, ‘/’, TRUE) . $category;
    }

    — Mark
    [email protected]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Apache 1.3 and /?tegory%/%postname%/ as permalink’ is closed to new replies.