2

I am trying to set up a development environment for Wordpress multisite on my local MAC. I am developing using PHPStorm, and the built-in PHP webserver. One of the limitations of the built-in webserver is that is doesn't support apache mod_rewrite, but instead uses routing scripts. However there's very little clear documentation on translating into these from .htaccess rules.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wordpress/$1 [L]
RewriteRule ^(.*\.php)$ wordpress/$1 [L]
RewriteRule . index.php [L]

Is where I'm starting from, the basic Wordpress redirect htaccess for a multisite with Wordpress in its own directory (/wordpress)... can anyone point me in a good direction for resources on how to translate this into a routing script?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Denny
  • 186
  • 1
  • 10
  • I don't think there's any way in hell WordPress multi-site is going to work with the local dev server. – ceejayoz Jul 16 '15 at 21:37
  • Actually, after much pain and abuse we have gotten it to run. When I have a moment I'll post the methodology here. The only annoyance is that there's no way to make the built-in listen to multiple host names (and we use a different domain for each location's site) so you have to stop and restart the server with the new hostnames. – Denny Aug 04 '15 at 15:24

1 Answers1

1

So we finally managed to get this to work (at least using different domains for each site). Here is what it took: Add a line near the beginning of wp-config.php to detect the hostname and define a constant with it:

define('APP_HOST', $_SERVER['HTTP_HOST']);

Then make the following wp-config changes:

/** URL to wp-content directory */
define('WP_CONTENT_URL', 'http://' . APP_HOST . '/wp-content');

/** Domain name of default WordPress website */
define('DOMAIN_CURRENT_SITE', APP_HOST);

(Note that our wp-content folder is seperate from our wordpress folder, our setup preference so we can update WP from git and not [that I know of] required.)

From there it should "update" itself depending on whatever hostname your server is running under. The limitations we've found are that the built-in web server won't run SSH (thus no SSH Admin), and that it doesn't do the /wordpress/wp-admin redirect. So to get to wp-admin you need to use local.sitename.com/wordpress/wp-admin/ to get there. The trailing slash is important as well, as it won't automatically add it.

Denny
  • 186
  • 1
  • 10
  • You are actually able to overcome the wp-admin rewrite limitation, have a look at this answer http://stackoverflow.com/questions/27381520/php-built-in-server-and-htaccess-mod-rewrites – Anton Abilov Apr 27 '16 at 08:06