WordPress.org

Forums

Easier permalinks solution. (5 posts)

  1. dtweney
    Member
    Posted 10 years ago #

    I've hit upon a simpler way to get simple permalinks using WP 1.5, without requiring the big, hairy .htaccess code that WP generates. For some reason I could never pin down, my web server never worked right with that code -- I would always get a 404 error page instead of the index.php output that a properly rewritten URL should have generated.

    In my solution, you still need to edit your .htaccess file but the code is a lot cleaner. Here's how to do it:

    1. In your WP directory, copy index.php to a file just called "archive" (no extension). Like this:

    cp index.php archive

    (this is assuming you don't have a folder called "archive" -- if you do, you'll need to pick a different name

    2. Edit your .htaccess file to add these lines:

    # force archive file to be read as PHP
    <Files archive>
    ForceType application/x-httpd-php
    </Files>

    3. chmod 744 .htaccess -- this will keep WP from overwriting your .htaccess file

    4. In the WP Permalink Options screen, set your URL structure like this:

    /archive/%year%/%monthnum%/%day%/%postname%/

    If you used a filename other than "archive," change the first bit of that line above.

    Then hit "Update Permalink Structure." WP will tell you to modify your .htaccess file now -- ignore it. You're already all done.

    Now what happens is that anytime someone enters an archive URL, it will get interpreted as the *file* "archive" -- which is the same as index.php. Just remember, if you update index.php, to copy it over to the "archive" file again.

    WP designers: You might consider making future versions of WP work this way. Those rewrite rules are *gnarly*!

  2. skippy
    Member
    Posted 10 years ago #

    Ryan's reduced rewrite rules aren't gnarly at all, and they work great!

  3. James Huff
    Volunteer Moderator
    Posted 10 years ago #

    I think Skippy meant to include this link: http://boren.nu/archives/2005/03/07/reduced-rewrite-plugin/

  4. skippy
    Member
    Posted 10 years ago #

    No, I meant to use
    http://boren.nu/archives/2004/10/08/alternative-rewrite-rules/
    But botched it. Thanks for the heads-up.

  5. James Huff
    Volunteer Moderator
    Posted 10 years ago #

    Not a problem. Both are still pretty darn easy to implement.

Topic Closed

This topic has been closed to new replies.

About this Topic