First Nettuts Tutorial – .htaccess

My First Nettuts Tutorial was published today! For those who follow my blog every week, this is the reason why I haven’t been able to post the last few weeks… because I’ve been putting all the time I would normally be blogging into a series of Nettuts tutorials.

htaccess examples

This tutorial covers the basics of .htaccess, Apache’s Per Directory Configuration Files. Fortunately, with the basics out of the way, I can move on to the cooler features such as GZip encoding and mod_rewrite for the next article.

Also the examples can be viewed here:

And the examples can be downloaded here:


7 Responses


martin on May 13, 2009 at 5:05 pm  #

hey im coming from nettuts and i have to say that your tutorial is quite good.
its not one of these psd2html tuts that come up every week.

your unix tutorial is great too.

keep up the good work!


martin on May 13, 2009 at 5:10 pm  #

btw: it would be great to be able to comment the unix tutorial ;)


Joseph Pecoraro on May 14, 2009 at 10:35 am  #

@martin: Thanks for the support. I didn’t really expect the overwhelming responses from the Nettuts tutorial. Its very cool.

As for the Unix Tutorial, its now three years old! Its actually one of my first websites and its due for an update. I’ll see if I can get around to updating it not only feature wise (comments) but also with new content. I’ve learned a lot since I wrote that. Heck, I wrote that when I was learning to use Unix myself!



Joey on July 4, 2009 at 5:30 pm  #

Thanks for this Joseph, will come in handy – it seems to me that we’ve got to a stage where the majority of people can perform these htaccess functions through the use of software / their web host control panel, but don’t neccessarily know how to write the actual code themselves – fine for when it works, but leaves them stuck when it inevitably breaks at some stage.


shin on August 10, 2009 at 10:04 am  #

I am reading your article whole day from 9am. I am a slow reader, it’s 4pm. :-( I am reading links in your articles as well.

May I ask questions?

Q1. Options -Indexes : Does this – sign indicate to hide and + sign indicate show?

Q2. I have a problem with the following.
# This you must edit. It is the absolute path to the .htpasswd file.
AuthUserFile /path/to/.htpasswd

In the source file you provided has ” double quotes before and after the path. Acturall double quotes in AuthName as well. Do I need this double quote?

Q3. Regarding the same code as above. I am using XAMPP. I could see from your screen shot that you must be using Mamp or something. Because it has localhost. Now my problem is that I am not able to work it. I think the problem is with path to the .htpasswd. I have this file in C:\xampp\htdocs\htaccessfiles directory. I tried all sorts of things like /.htpasswd, /.htaccessfiles/.htpasswd, etc. with no success. If you have any idea to the absolute path, could you tell me please.

Q4. I have not finished your article yet, but can you suggest a book or two to read to learn more?

Thanks for your article, I learnt many thing today. :-)


Joseph Pecoraro on August 10, 2009 at 10:31 am  #

@shin: Thanks for taking the time to read the article. All too often I get the feeling that people don’t actually read the full article, which is a shame. Anyways, here are my comments on your questions:

1: Yes, there is both a + and – and they mean show and hide respectively. However the +/- make modifications to any previous Options declaration. If there were not +/- then it would completely overwrite the previous declaration. At least now you can add/remove from the previous declaration without worrying about wiping out something you didn’t know was previously set. Check out:

2: Double Quotes are not needed unless the path contains something like a space character. Then it is nice to wrap the path in quotes so you don’t have to worry about the space messing up parsing of the directive. So to be safe you can always use quotes, but if your path doesn’t contain spaces you should be fine without them.

3: Yes, I’m using MAMP on a Mac. I don’t know what the best path would be. I would try looking into the global configuration file and observe the file path format that they use for any other commands. My guess is because you’re on a Windows machine you might need to use Window’s style paths. Either way, seeing what already works should give you an indicator on what you need to do.

4: I can’t recommend any from personal experience because I myself haven’t used any books. Everything I’ve learned I’ve done through content on the internet and the official documentation. I took a quick look on Amazon and this book seems to have gotten good reviews:

Also, I just submitted my next two tutorials on URL Rewriting (mod_rewrite) and GZip Compression. Hopefully they will get accepted. I spent over 50 hours working on the mod_rewrite tutorial, which includes the time I spent myself learning many of the small details. Eventually it got to the point where I felt I had to release something rather then continuing to put it off, so I didn’t have as many examples as I has hoped, but I did produce (what I feel is) the most informative tutorial about mod_rewrite’s syntax.

Once again, I appreciate your feedback. Cheers!


shin on August 10, 2009 at 11:36 am  #

Thanks for your reply. I hope I will see your article on NETTUTS soon. Actually you answered my next question about the next tutorial.
Thanks again.

Add a Comment