0

I set up the site network to use subdomains locally (on Windows 10 AMPPS) and my hosts file has:

127.0.0.1 localhost
127.0.0.1 www.wooco.dev
127.0.0.1 bumbashop.wooco.dev

C:\Program Files (x86)\Ampps\apache\conf\extra\httpd-vhosts.conf:

#### www.wooco.dev VirtualHost ####
<VirtualHost 127.0.0.1:80>
DocumentRoot "c:/program files (x86)/ampps/www/wooco.dev"
ServerName www.wooco.dev
ServerAlias www.wooco.dev *.wooco.dev
ScriptAlias /cgi-bin/ "c:/program files (x86)/ampps/www/wooco.dev/cgi-bin/"
  <Directory "c:/program files (x86)/ampps/www/wooco.dev">
  Options FollowSymLinks Indexes Includes ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
  </Directory>
ErrorLog "C:/Program Files (x86)/Ampps/apache/logs/www.wooco.dev.err"
CustomLog "C:/Program Files (x86)/Ampps/apache/logs/www.wooco.dev.log" combined
</VirtualHost>

.htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^wooco.dev$
RewriteRule (.*) http://www.wooco.dev/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

There must be a way to do this, right? Whatever configuration this is here I'm pretty sure this was how it was when I was able to run www.wooco.dev/wp-activate.php?key=........ to activate a subsite registration for bumbashop.wooco.dev, which now loads a blank page 200 OK rather than an error.

UPDATE: It's working now and I don't know how.

1

On a Mac this is pretty easy to do, I believe it should be the same on a PC (more or less).

Note: Since Chrome no longer plays with domains ending .dev I tend to set up all my local sites on a subdomain, eg: if the public site is www.example.com I would use dev.example.com.

In AMPPS set up the subdomain, remember to enable SSL if the public site runs over https. For this example I'll use dev.example.com

Next set up your WordPress Network to run in subdomain mode. Follow the instructions that WordPress gives you. You can, if you wish, add all of your networked sites at this point, but they will not be accessible.

Then open up your host file, on a Mac it is located in.

/private/etc/hosts

On Windows it should be located in.

C:\Windows\System32\Drivers\etc\hosts

AMPPS will have added an entry which looks like this.

127.0.0.1 dev.example.com

Under this add all the subdomains which you wish to have eg:

127.0.0.1 dev.example.com
127.0.0.1 en-gb.dev.example.com
127.0.0.1 de-de.dev.example.com
127.0.0.1 fr-fr.dev.example.com

Next open up the following file

/AMPPS/apache/conf/extra/http-vhosts.conf

I guess on a Windows machine this will be located within the programs directory.

Locate the VirtualHost entry which AMPPS has added for dev.example.com, find the line which reads

ServerAlias dev.example.com

And add a wildcard subdomain to it like so.

ServerAlias dev.example.com *.dev.example.com

If you enabled ssl for the subdomain at the start then you'll also need to amend the SSL VirtualHost, AMPPS normally places this below the entry you've just amended. Once again find:

ServerAlias dev.example.com

replace with.

ServerAlias dev.example.com *.dev.example.com

Now all what is left to do is to restart Apache in AMPPS.

You should now be able to visit both http://en-gb.dev.example.com and https://en-gb.dev.example.com without any problems (apart from the normal security error in Chrome).

Remember if you add more multisite you'll need to update your host file with the new ones.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.