• Speaking of magnets…

    I’ve been tasked with setting up WordPress on IIS 7 here and have been trying to wrap my head around how the URL Rewrite rules for Multisite work. The idea is that they want to essentially integrate WP into our existing site such that the main home page is the current static page, and then you’d have Multisite sub directories that are handled by WP along side normal, already existing sub directories. So, for example, http://www.foo.com brings up a standard, non-wordpress PHP home page, http://www.foo.com/news might be a WordPress “site”, but http://www.foo.com/recipes is just a sub directory with PHP pages.

    I’ve managed to make all of this work by renaming WordPress’s index.php to wp-index.php and then tweaking the final URL rewrite rule to use wp-index.php as the Action URL.

    What I’m trying to do at this point, though, is make sure I have a good, firm grasp of how the URL Rewrite rules are doing what they are doing. Most of them are pretty straight forward, but some of them have me a little puzzled and at this point, appear to be black magic.

    For example, this one:
    <rule name=”WordPress Rule 6″ stopProcessing=”true”>
    <match url=”^([_0-9a-zA-Z-]+/)?(.*\.php)$” ignoreCase=”false” />
    <action type=”Rewrite” url=”{R:2}” />
    </rule>

    From what I can tell, it’s matching on any request that ends with .php (so any php page) and stripping out the initial subdirectory. So “news/newsfile.php” becomes just “newsfile.php” and “news/yesterday/oldnews.php” becomes “yesterday/oldnews.php”. Now, I would expect this rule to completely torpedo my idea of having non-wordpress sub directories along side wordpress directories. But it doesn’t. Requests to things like http://www.food.com/news/todaysnews.php work just fine and are not rewritten to http://www.food.com/todaysnews.php like I would expect…. That’s great for me, but I’d sure like to know WHY. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    You dno’t need to do anything with the rewrites. Or shouldn’t/

    Install WordPress in root: food.com

    Make a subsite called News and call food.com/news

    Make a PHYSICAL folder called recipes and call food.com/recipes and it’s fine.

    However if you go to the non-existant site food.com/drinks, it will use WordPress’s 404.

    WordPress gives precedence to the physical folders, so you shouldn’t need to do anything. I do that all the time and never have a problem.

    Thread Starter MinisterOfPropaganda

    (@ministerofpropaganda)

    The only reason I tweaked the URL Rewrites was so that we could keep our existing “index.php” instead of using the one that WordPress installs. I suppose I could accomplish the same thing by renaming our index.php file to something like home.php and then making THAT the default document. 6 of one, half dozen of the other, but I guess the second way would not involve tinkering with the rewrites.

    Is there a discussion somwhere on what each rewrite is supposed to be doing?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The only reason I tweaked the URL Rewrites was so that we could keep our existing “index.php” instead of using the one that WordPress installs.

    That’s (generally) a bad idea. WordPress relies on that file to redirect its everything, so you’re gonna screw yourself up.

    It’s touched on here: http://core.trac.wordpress.org/ticket/16687 and Otto goes into some detail here: http://ottopress.com/2010/category-in-permalinks-considered-harmful/

    Thread Starter MinisterOfPropaganda

    (@ministerofpropaganda)

    Well, everything is still going through the WordPress version of index.php (just under a different name). The only exception is the actual index.php file itself. We’ll be doing a ton of testing before doing anything in production, though, and the web development folks that requested this have said it’s not a deal breaker if they have to just have the root pages served up by WordPress as well. So we’ll see how it goes. Thanks for the info!

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Well, everything is still going through the WordPress version of index.php (just under a different name).

    Are you sure? 🙂 There’s more than the obvious, and some things assume the file is there, and will break in funny says.

    tl;dr: Don’t move index.php unless you’re a supercoder who knows WordPress’ ins and outs already.

    it’s not a deal breaker if they have to just have the root pages served up by WordPress as well.

    You know you could make a static front page, and then link to your non-WP pages if you wanted. But … you’re using WP. You should, if possible, use it.

    Thread Starter MinisterOfPropaganda

    (@ministerofpropaganda)

    Hmmm. If other parts of WordPress reference it without being subject to the URL Rewrite rules (includes come to mind I suppose) then that would certainly be problematic. Thanks for the heads up. Seems like it wouldn’t be too difficult to either pull in or recreate the current page as a WordPress page.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘URL Rewrites! How do they WORK?’ is closed to new replies.