# Change Web Sharing “Sites” folder to SkyDrive?

I'm building a web site. There are three Macs that I commonly use for development, depending upon my location: an iMac in San Diego, and iMac in Vegas, and a MacBook Air in all other places. As I move from place to place, I have to copy the contents of the "[username]/Sites" folder from machine to machine so I can get my work done. It would be nice if I could just keep a master copy of the site files in one place.

So I signed up for the free cloud-based Skydrive storage. The pointer to the storage lives at "[username]/documents/SkyDrive". Anything inside that folder syncs across all of my Macs. Which leads me to my question…

How can I change the path that local web hosting uses (on OSX 10.8.2) to point to my SkyDrive folder instead of the default "[username]/sites"?

The goal is that when I navigate to "http://127.0.0.1/~[username]/index.html", the built-in OSX web server will pull in the index.html file from a SkyDrive folder. Hope this makes sense.

It's important to note that I won't actually be attempting to run a production website off of SkyDrive. No external users will be using the site in this manner. This is just to make my development processes a bit easier.

The simplest solution is to set up a symlink to your Skydrive-folder – this will save you a lot of time by avoiding the Apache-setup and such.

Copy the contents of ~/Sites to your Skydrive-folder (~User/Documents/Skydrive/Sites). Then open Terminal and type in the following command:

rm -rf ~/Sites
ln -s ~/Documents/Skydrive/Sites ~/Sites


Warning: This will delete your ~/Sites folder and it's contents, make sure you have a copy!

This will reroute all attempts to access ~/Sites to ~/Documents/Skydrive/Sites. Repeat this on all your computers.

I have used this for my games' savefiles, and it works like a charm!

• I like the simplicity. I'll try this and let you know the result. What does the "~" character mean? Is that a shorthand for "my user directory"... sorry I don't know unix. – Chad Decker Feb 17 '13 at 18:37
• That's a shorthand for the current user's home directory, yes. – Emil Feb 17 '13 at 18:38

Yes, you can change your web server's user-specific directory to point to another location within your home directory. Be aware there are security implications when doing this – aim to understand what they are before you proceed.

First, back up the configuration files mentioned below, then, use Terminal to edit the files as root; e.g. via sudo vi [filename].

1. Edit /etc/apache2/extra/httpd-userdir.conf, changing the UserDir value from 'Sites' to the new target folder within the home directory structure. Note: This directive changes the Sites folder location for all users .. I'll assume there's just you and this is OK.

2. Edit the corresponding user-specific configuration file in /etc/apache2/users/[username].conf so the path mentioned in the Directory directive matches what you set above. This ensures the options that were originally being applied to your Sites folder will be applied to the new location.

3. Ensure permissions to the new folder (including directories leading to it) are permissive enough for the web server process to access.

4. Restart the apache web server; i.e. sudo apachectl restart

That should get it working.

• thanks so much! I'll run through the steps and let you know how it goes. – Chad Decker Feb 17 '13 at 18:36