URL Rewrites! How do they WORK?
-
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. 🙂
- The topic ‘URL Rewrites! How do they WORK?’ is closed to new replies.