Forums

Rewriting ?p=352 to 000352.php (15 posts)

  1. jzader
    Member
    Posted 4 years ago #

    I'm a convert from MoveableType, and I'd like to preserve the permalink naming convention that I had from my MT installation. How can I cause WordPress to make permalink URLs that look like this?

    http://www.theatlasphere.com/metablog/000352.php

    It looks like WordPress has a lot of built-in functionality in this regard, so I thought I'd see if it can be done within WP before I go try and fumble through learning how to write the htaccess code myself!

  2. Denis-de-Bernardy
    Member
    Posted 4 years ago #

    did you try the following permalink structure?

    %post_id%.php

  3. pizdin_dim
    Member
    Posted 4 years ago #

    Good one Denis, that will work, except it won't be zero-filled, so it will be like this instead:

    http://www.theatlasphere.com/metablog/352.php

    Is that ok? If not, I think you'll have to hack the code to achieve zero-padding in permalinks.

  4. jzader
    Member
    Posted 4 years ago #

    UH-OH. I was playing around with these suggestions, and now whenever I try to go to the blog, I get an error in FireFox: "redirection limit exceeded".

    And I get the same error within the WordPress admin console, which means I can't make any further changes from within WordPress.

    I've tried removing the relevant code from htaccess, and that doesn't help.

    HALP?!? :-) Seriously, this is obviously a major problem. Any expeditious suggestions would be gratefully appreciated.

  5. jzader
    Member
    Posted 4 years ago #

    OK, solved my crisis. :-)

  6. Kafkaesqui
    Moderator
    Posted 4 years ago #

    The "zero problem" is resolved by editing the template-functions-links.php file (wp-includes\ directory). Under the get_permalink() function look for the $rewritereplace array, and in it change:

    $post->ID,

    to:

    zeroise($post->ID, 6),

    That uses the WP function zeroise() to force the ID to 6 places by inserting zeros at left when it's less than 6 digits.

    When modifying source files, back up any you are editing, and comment your changes for future reference.

  7. pizdin_dim
    Member
    Posted 4 years ago #

    Well done Kafkaesqui, I obviously haven't spent as much time in the code as you have!

  8. Kafkaesqui
    Moderator
    Posted 4 years ago #

    Believe me, I've spent far TOO much time in it! :/

  9. jzader
    Member
    Posted 4 years ago #

    I haven't gotten to the part yet about fixing the zeroes. But I'm already getting 404 errors.

    Here's what I'm doing... When I update my permalink structure in options-permalink.php to %post_id%.php, and then update my .htaccess file with the provided code, then return to the main page of my blog, reload, and click on a link to an individual entry ... I get a 404 error.

    I have the same problem if I use %post_id% without the .php part.

    What would cause this?

  10. Kafkaesqui
    Moderator
    Posted 4 years ago #

    Does your server support mod_rewrite?

  11. pizdin_dim
    Member
    Posted 4 years ago #

    update my .htaccess file with the provided code

    Huh? Why do you need to do this? Wordpress updates the .htaccess for you.

    And, you will need an web server enviroment that supports "mod rewrite".

  12. jzader
    Member
    Posted 4 years ago #

    My server does support mod_rewrite and I use it successfully.

    Why do I update my .htaccess file manually? Because I have my .htaccess set so that it is not writeable. I want to make sure that WordPress doesn't muck up any of my custom redirects, etc.

    I just never cared to find out what happens when it edits the .htaccess by itself. So I copy the code that it provides, and paste it into the end of my .htaccess.

    For the record, I did try removing all of my code from the .htaccess, to make sure that it wasn't any of my prior code that was causing the problem. It had no effect.

  13. jzader
    Member
    Posted 4 years ago #

    OK, just to reiterate.... I'm still having a problem with getting 404 errors when I try to use WordPress's URL rewrite functionality. Any ideas about what's causing it?

  14. jzader
    Member
    Posted 4 years ago #

    Follow up.... I was able to fix the 404 problem by letting WP write its own htaccess files.

  15. billsaysthis
    Member
    Posted 4 years ago #

    I have no special settings on .htaccess and do have mod_rewrite in place. Yet when I make the permalink option /%post_id%/, or /%post_id%, I get a 404 on clicking any permalink.

Topic Closed

This topic has been closed to new replies.

About this Topic