Project:Subdomain
Version:6.x-1.4
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)

Issue Summary

I installed and set-up the Subdomain module on my live site. I would now like to go back to working locally. However, I'm finding that when I attempt to log-in all of the tabs on the .../user page point back to the live site's URL, not my local directory. Thus it tries to log me in the wrong site and I'm effectively locked out.

As far as I know the only place I entered the live domain into the site anywhere for it the remember was during the set up of the subdomain module... in the setting.php file to replace:

$cookie_domain = 'example.com';

How should I update this to work for my MAMP install. Just obvious does not work:

$cookie_domain = 'localhost:8888/directoryName';

Any thoughts?

Perhaps there is something I need to know about configuring MAMP for Subdomain to work?

Thanks!

Comments

#1

Status:active» postponed (maintainer needs more info)

hmm... i haven't tried it on a mamp install, so I'm not certain.

If anyone has any ideas, please comment.

#2

subscribe

#3

I have a few aliases setup in my hosts file that point to 127.0.0.1:

I then have my cookie domain set to '.localhost'. The cookie isn't shared between the subdomains properly so I'm not logged in across all of them, but it does rewrite the URLs correctly. The one downside with this technique is that I have to manually add an entry to my hosts file for each subdomain I'm testing.

I haven't had a chance to dig into what it would take to get the cookie to actually work properly. It would likely require using full domain names in the hosts file such as 'www.foo.com', or some other domain name that I'd never actually need to get to.

#4

I've come up with a better setup for doing subdomain development under MAMP that does not require messing with the hosts or apache config for each new subdomain.

First you need to install and configure DNSMasq via Mac Ports:

# Add example.com as localhost to /etc/hosts
127.0.0.1  dev

# Install dnsmasq
sudo port install dnsmasq

# Add line to the top of /opt/local/etc/dnsmasq.conf
address=/example.com/127.0.0.1

# Start dnsmasq and set to launch at startup
sudo port load dnsmasq

# Open Mac Network Preferences
# Set DNS server as 127.0.0.1 + existing server
# If existing DNS is 10.0.0.1
127.0.0.1, 10.0.0.1

# Check that it's working
dig google.com

# Should return results from
# ;; SERVER: 127.0.0.01

# Test dev domain
ping example.com

# Should return something like
# 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.031 ms

# Also test example.com subdomains
ping foo.example.com

# Should return similar results

Next comes the Apache config magic:

DocumentRoot "/Users/rwohleb/Desktop/WWW/default/docroot"

NameVirtualHost *:80

<VirtualHost *:80>
    VirtualDocumentRoot /Users/rwohleb/Desktop/WWW/%-3/docroot
</VirtualHost>

Make sure that the default document root exists else apache will barf. Also make sure to substitue your username ;)

Now all of your subdomains will be served from "/Users/rwohleb/Desktop/WWW/%-3/docroot". This means that foo.example.com and www.foo.example.com will both be served from "/Users/rwohleb/Desktop/WWW/foo/docroot".

References:
1) The 'Setting up DNSMASQ' section from: http://davesouth.org/stories/how-to-set-up-dnsmasq-on-snow-leopard-for-l...
2) The 'NOW FOR THE APACHE MAGIC!' section from: http://postpostmodern.com/instructional/a-smarter-mamp/