mod_rewrite, wordpress, and multiple domains
-
I’m insanely confused about using mod_rewrite and wordpress together with multiple domain names.
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 https://www.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 ... the usual wordpress .htaccess stuff ...
The /index.php in the 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.
Anyhow, it’s 1:30am in the morning, and this seems to work. I just don’t understand how or why it works.
Thanks,
Scott
- The topic ‘mod_rewrite, wordpress, and multiple domains’ is closed to new replies.