WordPress.org

Support

Support » How-To and Troubleshooting » Mod Rewrite: What actually is this?

Mod Rewrite: What actually is this?

  • Hi there,
    Sorry if this is too basic a question but I gotta know 🙂
    I have been reading articles on archives and noticed that a lot of people mention mention the following:
    RewriteRule ^archives/?$ /archive.php
    As I understand this, this means that archive.php can be in the root and not in a folder called ‘archives’ and so when you click on a link called archives it mimics a folder called ‘archives’
    My question is why would you do this over having an actual folder called ‘archives’ with the file archive.php in it?
    Further to this, do you guys use this mod rewrite for all your additional pages that are use the links from wordpress but not the actual blog?
    Thanks
    Chris

Viewing 8 replies - 1 through 8 (of 8 total)
  • Great questions.. I was wondering this myself. I would like to know, first, how to do this because the wiki instructions weren’t entirely clear to me—and if this can be used for a “links” and “about me” page as well.

    TechGnome

    @techgnome

    Moderator

    If I’ve understood things right, having the rewrite will allow you to have archive links similar to the permalinks of root/year/month/day/postname… but uses the archive.php template instead of index.php. This allows your archive to have a different look. As for why that instead of just having an archive folder…. I think the links come out looking like this:
    /root/archives/year/month/day/postname
    You aren’t going to actually create each of those folders. They become virtual.
    It’s simply a nicety thing and makes it easier for search engines like google to index pages (if I’ve heard right)
    TG
    DISCLAIMER: All of the above are my understanding. It maybe wrong. I don’t know 100% for sure.

    @ debwire,
    I’ve created better instructions for using photomatt’s archive style. View them here.
    As far as not having an archives folder, I do it for the reasons TG noted. We don’t have an archives folder for all of the archives, so why have it for this one file?

    I’ve been playing with creating actual dirs named /archives/ and /category/ and the rewrite will not allow .html type pages under the category/ dir, but will under the /archives/ dir, i.e., /archives/xx.html can be browsed, but the WP hides the xx.html under category/ – this is all when the dirs actually created, and not virtual mod rewrite. I wonder why the difference.
    I’m hunting around for info regarding other dir names than “archives” and “directory”. Are these categories required by the php code as written, and difficult to amend? For instance, /pets/cats/ instead, for an example.
    My vitrual /category/ level is cranky – no post match “criteria” and the title of the page at
    http://nommune.com/archives/category/
    is:
    <title>nommune<div id=’error’>
    SQL/DB Error:
    [<span style=’color: #007;’>You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1</span>]
    SELECT * FROM wp_posts WHERE ID =
    </div> » </title>
    Anyone else?

    No posts will match the criteria for http://nommune.com/archives/category/ since you didn’t pass a category name.
    You need to call something like http://nommune.com/archives/category/cats/ which will pull up all posts filed under the cats category.

    Mt, your site doesn’t exhibit the title errors for
    http://mtdewvirus.com/archives/category/
    that mine is giving. It’s the only page I’ve seen on my installation that does it, and I noticed it on Google results first. Still a problem.

    Is there instructions anywhere?

    Mtdew, thanks for putting up instructions but i get a 404 following that link. I’d love to see some info on this too, I have actually RTFM from apache on the whole mod_rewrite thing but it kinda makes my brain melt… cheers

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Mod Rewrite: What actually is this?’ is closed to new replies.