WordPress Code Snippets

A fresh mix of code snippets and tutorials

Create .htaccess files on OS X and Windows


Quick tutorial on how to create .htaccess files on Windows (PC) and OS X (Mac).

About .htaccess files

.htaccess files (or “distributed configuration files”) provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

By default .htaccess files are hidden on Windows and OS X, so you can’t just right-click and create a new .htaccess file. But it is certainly is possible, as explained in the following sections of this tutorial.

Note that if you just want to view .htaccess files (and don’t need to create them), you can simply enable your machine to show hidden files. Or use any FTP or code-editing software that is capable of displaying hidden files (it’s a common feature).

The easy way to create .htaccess files

The easy way to get an .htaccess file on your machine — whether Mac or Windows — is to just download a copy from a reliable source. In my book, The Tao of WordPress, I make it easy for readers to grab a copy of a blank .htaccess file directly from my server:

Download blank .htaccess file

That’s gonna put an .htaccess file in your machine’s default download directory. Of course, .htaccess files are hidden by default, so jump ahead to either section to learn how to view them on either Windows or OS X.

Create .htaccess files on PC / Windows

Note that I no longer use Windows, so the screenshots here are from WinXP (which was the last version of WordPress that I owned). So things may look or work a bit different depending on which version of Windows you’re using.

That said, here are the steps to create a new .htaccess file on a Windows machine:

  1. Step 1: Open a new text file and add your .htaccess code
  2. Step 2: Select File > Save As..
  3. Step 3: In the “Save As” box, name the file “.htaccess”
  4. Step 4: In the “Save As” box, specify “All Files” for “Save as type”
  5. Step 5: You now have a new .htaccess file on your Windows machine

Note: .htaccess files are hidden by default, so to view the file you need to enable “Show hidden files” on your machine. The setting for this varies depending on your version of WordPress, so refer to the manual if needed. Once you enable hidden-file display, .htaccess files should be visible.

Alternately, you should be able to view hidden files such as .htaccess using any decent FTP program or code editor.

Create .htaccess files on Mac / OS X

The process for OS X basically is the same as it is for Windows. Here are the steps (without screenshots):

  1. Open a new TextEdit file
  2. As you save the file, name it “.htaccess”
  3. A dialogue box will popup with “Names that begin with a dot are reserved for the system.” That’s fine, go ahead and click OK to use the dot.
  4. Done.

Like Windows, OS X considers file names that begin with a dot as system files, so they are not visible by default. To view them, you can use just about any good FTP program, or install an app that can display hidden files on your machine. There also are Terminal commands to display all hidden files. This search query should help.

Bonus: Show/Hide Files via Terminal

Here are some commands for showing and hiding hidden files on Mac via Terminal:

Show hidden files

Hide hidden files

That’s all folks, happy .htaccess’ing :)

Learn more

.htaccess made easy

Show Support

Like our new Facebook Page to show support!