Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two projects that are a copy of each other on my Mac with MAMP. They both have SSL pages. However, whenever I hit the a secured SSL page of project 2, the base_url or host changes to project1 instead of remaining project2. I know this is an issue with the vhosts, because if I switch the order of the entries, the reverse happens. Here's my config files:


<VirtualHost _default_:443>
DocumentRoot "/Applications/MAMP/htdocs/proj1"
ServerName proj1.localhost:443
ErrorLog "/Applications/MAMP/Library/logs/error_log"
TransferLog "/Applications/MAMP/Library/logs/access_log"
SSLEngine on
SSLCertificateFile "/Applications/MAMP/conf/apache/ssl/server.crt"
SSLCertificateKeyFile "/Applications/MAMP/conf/apache/ssl/server.key"

<VirtualHost _default_:443>
DocumentRoot "/Applications/MAMP/htdocs/proj2"
ServerName proj2.localhost:443
ErrorLog "/Applications/MAMP/Library/logs/error_log"
TransferLog "/Applications/MAMP/Library/logs/access_log"

SSLEngine on
SSLCertificateFile "/Applications/MAMP/conf/apache/ssl/server.crt"
SSLCertificateKeyFile "/Applications/MAMP/conf/apache/ssl/server.key"

cat /etc/hosts

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##   localhost broadcasthost
::1             localhost 
fe80::1%lo0 localhost proj1.localhost proj2.localhost
share|improve this question

closed as off-topic by Falcon Momot, Ward, Ladadadada, mdpc, Nathan C Jul 2 '14 at 18:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Falcon Momot, Ward, Ladadadada, mdpc, Nathan C
If this question can be reworded to fit the rules in the help center, please edit the question.

Does the URL in the browser's address bar change, or do you just get the wrong content? – Shane Madden Oct 8 '12 at 3:30
up vote 2 down vote accepted

Change the

<VirtualHost _default_:443>


<VirtualHost *:443>

Then make sure you have

NameVirtualHost *:443

Then restart apache and it should work


Also you don't need the 443 in ServerName proj1.localhost:443

share|improve this answer
Thank You Mike! – user1322092 Oct 8 '12 at 11:13

This is because the hostname is sent encrypted, and the SSL decryption happens inside the virtual host, not outside it. This means that the server doesn't have access to the hostname when it selects the virtual host, and thus it will always select the first one. You can read more about this at

share|improve this answer
not 100% true.. it will use the SSL cert from the first entry it sees but if setup correctly after ssl is decrypted the host header is read and it will go to the correct docroot – Mike Oct 8 '12 at 13:08
This is only true for older browsers (and potentially operating systems) and/or older versions of Apache. Current versions of Apache and any current browser available on a Mac will support SNI. – Ladadadada Oct 9 '12 at 9:18

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