Wordpress subdomain on localhost
Because of the requirement of a site in the network called 'blog', I had to use sub-domains instead of subfolders. WordPress doesn't allow a subfolder called 'blog'.
Anyway, so I added these changes in my hosts file:
- 127.0.0.1 site1.localhost
- 127.0.0.1 site2.localhost
- 127.0.0.1 blog.localhost
Then I went to my httpd.conf file and added the setup for each individual subdomains for localhost:
For site 1:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
ServerAlias site1.localhost
Docum开发者_Go百科entRoot "..\htdocs\wordpress\site1"
DirectoryIndex index.php index.html index.html index.htm index.shtml
</VirtualHost>
and so on for site2 and blog. I am a little unsure about using * there. I think something else goes there. :/
I went on to activate multisite in my wp-config file as:
define('WP_ALLOW_MULTISITE', true);
But, at the end of the process I'm getting this message:
Because you are using localhost, the sites in your WordPress network must use sub-directories. Consider using localhost.localdomain if you wish to use sub-domains.
What must I do to get subdomains then?
Would really appreciate your help here. Thanks!
First, the *
is a wildcard. Basically, you're telling Apache to listen to port 80 on all IPs pointed at the server. For localhost, no big deal. But if you had multiple IPs pointing at a host, you'd substitute the IP for the *
in the VirtualHost
declaration.
IE:
NameVirtualHost 123.4.5.6:80
<VirtualHost 123.4.5.6:80>
...
Now on to the error message. Basically, WordPress sees "localhost" and assumes you're testing locally and won't be setting up subdomains. My recommendation would be to use a different host and set up your system to act appropriately (Basically, localhost
can't have subdomains unless you set up up in a specific way to begin with).
So instead, use site1.local
, site2.local
, blog.local
and so on. Then change your hosts file and httpd.conf file the same (substitute local
everywhere you used localhost
).
精彩评论