How to change the name of the "Sites" folder on Mac OS X

If you're on Mac OS X and would like to change the name of the Sites folder in your home directory to something else -- and have it still work as designed -- start by turning Apache off via Web Sharing in the Sharing pane under System Preferences.

(By the way, if you're reading this in the Celsius1414 RSS or Atom feeds, I'd recommend coming to the actual webpage to make sure all the code displays properly.)

Next, open up a Terminal window and browse to the /etc/httpd directory. You're going to edit a couple of files under this directory.

First up is httpd.conf. You'll want to create a backup of it just in case, so start by doing the following -- add a number to the end of ".bak" if a ".bak" already exists.

sudo cp httpd.conf httpd.conf.bak

Next, open up httpd.conf to edit in your favorite text editor, such as vim:

sudo vim httpd.conf

Inside this file, there are two locations where we need to change "Sites" to the name you want to use -- in my case, "www".

The first place is around line 420, which says UserDir Sites

Change it to

UserDir www

Then just below, about line 427, change

#<Directory /Users/*/Sites>

to

#<Directory /Users/*/www>

Save and exit the file.

Now we need to change things inside the "users" directory under /etc/httpd, so cd there. Inside are individual config files for every user on the system. If your username is alincoln, you'll find your own config file with the name "alincoln.conf". Open this file in your editor (feel free to back it up first):

sudo edit alincoln.conf

You won't find but a few lines inside, and the very first line is what we need to edit. Change this:

<Directory "/Users/alincoln/Sites/">

to

<Directory "/Users/alincoln/www/">

then save and exit the file.

And that's it! Go back to System Preferences and turn Web Sharing back on. You can test your edits out by going to your web browser and this URL: http://127.0.0.1/~alincoln/

Didn't work, did it? That's because you need to change the name of the actual "Sites" folder in your home directory to "www" -- once you do that, the url will work. Enjoy your new folder!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Allowed HTML tags: <a> <cite> <code> <strong> <em> <blockquote> <b> <i> <p> <br> <ul> <ol> <li> <small>
  • Lines and paragraphs break automatically.

More information about formatting options