Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP The .htaccess File

Where to learn how understand server Configuration files.

Alena mentions that she's modifying the htaccess file, which is a configuration file for the Apache server. She changes a setting to -1 which she explains will mean all, but where could one learn more about what the settings/language (I don't know what this would be called since she expressly said that this isn't a programming language) of configuration files for servers? **Note: I don't understand a lot of the replies in Stack Overflow, and Developer sites...if you have other options that would be fantastic. Thanks!

Scott Lougheed
Scott Lougheed
19,390 Points

the .htaccess file is an apache configuration file that does a lot of things, ranging from simple URL redirects, to modifying certain aspects of the server.

It is "code" that you are writing, though as Alena indicates, it isn't PHP code.

In that video Alena is using .htaccess to override some of the PHP settings for the server, in this case pertaining to various settings related to error logging. The specifics of these settings can be find on php.net. These settings all accept "values". In some cases the value is either "on" or "off". In other cases, there may be a range of acceptable values.

For example, the setting that Alena changes to a value of -1 can be read about here: http://php.net/manual/en/function.error-reporting.php

You'll see that there are a number of possible values:

<?php

// Turn off all error reporting
error_reporting(0);

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors (see changelog)
error_reporting(E_ALL);

// Report all PHP errors
error_reporting(-1);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>

We can see that a value of -1 is "Report all php errors", while a value of 0, which was the default, is "Turn off all error reporting". In the video you are being instructed on how to turn on error reporting and logging on a PHP server, hence the change from 0 "turn off all error reporting" to -1 "report all PHP errors",

It's okay if you didn't know what 0 or -1 corresponded to, that's why there're things like php.net!

As to where you can learn more about .htaccess, as you have just learned, .htaccess is very powerful and can do a lot of things. Redirects (covered elsewhere on Treehouse) and error logging are probably some of the most important things most users doing day-to-day web stuff will need, and even then you'll likely not be modifying .htaccess regularly.

Unless you are regularly setting up, maintaining, and reconfiguring Apache servers you'll probably only use ,htaccess for a limited number of things. I think you'd be best to look up the specific task you are trying to perform than to attempt to learn everything .htaccess is capable of.