I’m having a diffucult time getting the ReWriteRules and URL structures setup for a WordPress 3.4.2 (latest version as of this post) blog with multi-site enabled.
www.ourdomain.com/ is the homepage of an e-commerce site.
We also have
www.ourdomain.com/example-category/
and
www.ourdomain.com/example-product/
As our category and product URL structures. This is all working.
I have installed the wordpress files in the physical folder /var/www/ourdomain/wordpress. Right now, www.ourdomain.com/wordpress/ goes to the default blog. www.ourdomain.com/wordpress/blog1 is the first blog and www.ourdomain.com/wordpress/blog2 is the second.
I’ve got to this point by adding
ReWriteRule ^/wordpress - [L,NC]
to our vhost file (.htacess is diasabled).
Our intention is for direct requests (from users) for www.ourdomain.com/wordpress(/*)
to redirect to the home page www.ourdomain.com/
since the /wordpress
folder is just to store files, not intended as an actual blog for users to access.
Requests for www.ourdomain.com/blog/
should silently redirect to www.ourdomain.com/wordpress/blog1
. Requests for www.ourdomain.com/policies/
should silently redirect to www.ourdomain.com/wordpress/blog2
.
So:
/wordpress/ -> 301 /
/blog/ -> silent /wordpress/blog1
/policies/ -> silent /wordpress/blog2
It seems simple in theory, but not so simple in practice.
I started with:
ReWriteRule ^/wordpress - [L,NC]
RewriteRule ^/blog/(.*)$ /wordpress/blog/$1 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/blog/ /wordpress/blog/index.php [L]
Which results in a 404 at /blog/. Of course, because /wordpress/blog/index.php
isn’t a file. There is no blog
folder inside the wordpress
folder. The file I want to load is /wordpress/index.php
, which reads the URL to determine which blog to load- But the URL has been modified, so this fails. I need a way to invoke /wordpress/index.php
from the URL /blog/, but make /wordpress/index.php
see the request as if the user went to /wordpress/blog
.
Any way to pass a fake URI to PHP from modRewrite? Or an alternative way to achieve this without installing to separate copies of WordPress?
UPDATE:
Since this doesn’t seem to be supported in the current version, but I still need this working before the new version is released, I think a work around would be to use something like:
RewriteRule ^/blog/ /wordpress/index.php?site=blog [L]
And then modify the WordPress file that reads the URL and have it set the site variable based on the GET parameter instead. Would that work? Which file contains the code to set the current site?
This is currently not possible for a multisite setup. It should be possible in WordPress 3.5 which is planned to be released next month. So your only solution is: wait.Update December 26: This is now possible in WordPress 3.5 without further hacks. 🙂