Mod Rewrite: What actually is this? (9 posts)

  1. Anonymous
    Posted 11 years ago #

    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?

  2. debwire
    Posted 11 years ago #

    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.

  3. TechGnome
    Posted 11 years ago #

    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:
    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)
    DISCLAIMER: All of the above are my understanding. It maybe wrong. I don't know 100% for sure.

  4. Nick Momrik
    Posted 11 years ago #

    @ 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?

  5. Nom
    Posted 11 years ago #

    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
    <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?

  6. Nick Momrik
    Posted 11 years ago #

    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.

  7. Nom
    Posted 11 years ago #

    Mt, your site doesn't exhibit the title errors for
    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.

  8. Anonymous
    Posted 11 years ago #

    Is there instructions anywhere?

  9. eric
    Posted 11 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.