This started out as a question to the wordpress folks, but it really has more to do with mod_rewrite.
Let me start by describing the scenario. I have two domains, site1.com and site2.com. Site1.com is the primary domain of my site and points to the root of my html directory tree. Site2.com is a secondary domain that points to /site2/ inside of site1.
site1:
/.htaccess - apache htaccess file
/index.php - wordpress index for site1
/wordpress - the guts of the wordpress installation
/site2/ - files for site2.com
/site2/index.php - a wordpress index.php that includes /wordpress/wp-blog-header.php (i.e. site1's wordpress installation)
Now, what I want to do is to have some pages of site2 rewritten to pages in site1. For example, lets assume I want [
site2.com...] to return page #360 on site1.
I've tried a number of things that should have worked but didn't. I finally settled on this, which shouldn't work but does:
site1:/.htaccess:
RewriteCond %{HTTP_HOST} ^www\.site2\.com
RewriteRule ^site2/$ /index.php?page_id=360 [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The /index.php in my rewrite rule doesn't seem to mean anything. I can change it to anything I want. For example, this will work:
RewriteRule ^site2/$ /somepagenameimadeup?page_id=360 [L]
The page_id=, well that does matter. It's the ID of the page I want displayed.
What I don't get is that I'm using the [L] flag on the rewrite rules, which (if I understand correctly) is supposed to prevent further rewrite rules from being applied. By my reckoning, rewriting it to /somepagenameimadeup?page_id=360 should have resulted in a 404 error and we'd be done with it. But... it didn't. It managed to make it to an index.php (the index.php in /site2/index.php to be specific) and actually render page #360.
I'm also greatly confused about the last rule in the wordpress section. The one that rewrites '.' to index.php. If '.' matches any single character, then doesn't wouldn't this replace one character with index.php? For example, "http://site1.com/foobar" --> "http://site1.com/index.phpfoobar" ?
Thanks,
Scott