Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Kevin Murphy
Kevin Murphy
24,380 Points

.htaccess file - Wordpress -- What is this file and it's role specifically?

Had a friend with an .htaccess permissions issue today. Reminded me that I have been curious what this file does and why sometimes the permissions need to be altered etc. Haven't found a concise explanation, I've even read that in some cases use of the file is optional?

Any experienced WP developers out there that could clarify this? Perhaps a practical example of its role? Greatly appreciated.

2 Answers


Fundamentally, .htaccess is an Apache web server configuration file. It's commonly used to override other configuration settings, especially at the directory level--customizing error pages, access control (to directories, for example), and more.

With WordPress, the primary use of .htaccess is security (access control).

Here's a great, comprehensive resource:


Here's what the WordPress Codex says about it:


Here's the Apache page about it:


And this discusses WP and .htaccess together, in the context of security:


Oh, and in case you were interested: it stands for "hypertext access".

Kevin Murphy
Kevin Murphy
24,380 Points

Hi James - thanks for these resources! I had read the Codex but wasn't connecting the dots to a practical use case.

I'm in the process of digesting this information. As I'm doing so, I'm still struggling with a few questions. (also I see that an .htaccess file is created by WP when user adds pretty permalinks - not sure how that relates to Apache server but not important at moment) .

Is it common that the permissions in the .htaccess file can be corrupted? And if so what is the go to method to fix? FTP a new .htaccess file or command line the proper permission settings in (as it seems the codex suggests)?


Kevin Murphy
Kevin Murphy
24,380 Points

Found a great article that explains in practical terms what each line of a standard WP .htaccess file does and how relates to permalinks. Wordpress' .htaccess file

Kevin Murphy
Kevin Murphy
24,380 Points

Also would recommend viewing/reviewing this excellent breakdown of permissions using the command line in the Treehouse library Treehouse Course: Console Foundations - Users and Permisssions. A quick review should have been step 0 for me, prior to diving into intricacies of htaccess.