Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I´m trying to set up a local development environment for me to work on a Wordpress multisite that I´m building. I use Mamp Pro with default ports (Apache: 80, MySQL: 3306), and I also added a new host with the same domain name as the page will have when going live. So, now when I go to http://mylivedomain.com I get to my development page, and database entries seem to use the same url as it should when going live as well. Enabling multisite from here was no problem, but I´m struggling to get Wildcard subdomains to work.

In the advanced tab under Host in Mamp Pro, I added: "ServerAlias *.mydomain.com", but that doesn't work for me. I´m able to add a new site from the Admin dashboard, but when trying to visit it I just get a 404.

Can anyone steer me in the right direction? I´m the 'design guy' so all this techinical jizz is really over my head, but I try...:)

share|improve this question

3 Answers 3

up vote 7 down vote accepted

Appart of the default ports and correctly configuring WPMS...

In the Advanced Tab:
MAMP PRO

And manually add the subdomains in /etc/hosts1 file:

# BRASOFILO MULTISITE START 
127.0.0.1 test1.brasofilo.dev
127.0.0.1 test2.brasofilo.dev
127.0.0.1 cloned.brasofilo.dev
# BRASOFILO MULTISITE STOP

1 The folder etc is at the root of your HD and it's hidden. You can open the file using TextMate or with your FTP client (enabling Show hidden files). It can also be done with the Terminal, but I don't use it for that and you'll have to search How To...

share|improve this answer
    
So the Customized virtual host general settings should read: ServerAlias mydomain.com *.mydomain.com ? I had typed: ServerAlias *.mydomain.com - That is wrong? Also, I was under the impression that Wildcard DNS allowed me to create any subdomain at will, but you mean I also have to specify the subdomains I will be creating in the host file? –  Johan Dahl Jul 2 '12 at 8:21
    
Yes, that's the correct ServerAlias setup. And, yes, you gotta manually add the subdomains. A tutorial that explains how to do it in MAMP, in MAMP PRO the Apache config file part is done in the Advanced tab. –  brasofilo Jul 2 '12 at 8:25
    
Thank you, that did the trick - works well now! - A related question: I my head, developing like this would mean that I don´t have to search and replace the url:s in the database when I deploy the site live, as long as the domain name is the same. Is this correct? Is this "smart" or should I go about it some other way? –  Johan Dahl Jul 2 '12 at 8:28
    
No need to play with your hosts file, just add another host in MAMP Pro. This answer would be fitting for users without Pro. –  Nick M Oct 27 at 4:08

If you are using MAMP Pro you can simply just add another completely new host using your sub-domain and then just route it to the same place as your top domain.

You won't have to add any virtual hosts in your original domain, or have to stuff around with your hosts file.

share|improve this answer

Can you update your .htaccess file manually, Copy the settings from from Network Setup and then open your .htaccess file in your editor and copy&paste. You have to enable to see invincible files on your computer, it should be something like this:

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

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
share|improve this answer
    
Yes I can update it, but, should I replace it´s content with the code you submitted here? I tried and it didn't do any difference. My .htaccess looks like this: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L] Argh..How do I make line breaks in commments? –  Johan Dahl Jul 2 '12 at 8:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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