Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by pctony: http://wiki.apache.org/httpd/ScratchPad/htaccess The comment on the change is: update 2 - still in progress. Heavy formatting work to be done. ------------------------------------------------------------------------------ == What is the purpose of .htaccess files? == - The purpose of .htaccess files is to provide a means to configure Apache for users who cannot modify the main configuration file (usually httpd.conf; see [["Info/DistrosDefaultLayout"]]). + The purpose of .htaccess files is to provide a means to configure Apache for users who cannot modify the main configuration file (usually httpd.conf; see ["Info/DistrosDefaultLayout"]). == .htaccess myths == @@ -33, +33 @@ 1. When server performance is of concern to you. As these can have a negative impact on server performance. 1. When untrusted people host websites on the server. (See notes on how to disable .htaccess files) + === But it's ugly having all that stuff in the main config file === Well, it might be, but you can use the Include directive to alleviate that if it really bothers you! @@ -43, +44 @@ {{{ Include /usr/local/apache2/conf/vhosts-protection/*.conf }}} - for all those directives to take effect. '''/usr/local/apache2/conf/vhosts-protection/vhost-1.conf''' {{{ @@ -88, +88 @@ You must place the .htaccess file in the directory where you want it to effect changes. For example if you want to use a .htaccess file to force authentication for www.example.com/admin - If your !DocumentRoot is ''/var/www/html/www.example.com'' then you would place your .htaccess file in ''/var/www/html/www.example.com/admin'' + If your !DocumentRoot is + {{{ + /var/www/html/www.example.com + }}} + + Then you would place your .htaccess file in + {{{ + /var/www/html/www.example.com/admin + }}} == How can I prevent users from using .htaccess? == @@ -101, +109 @@ ... </Directory> }}} + + ''Remember the use of a <Directory> block is recursive. So if you set at the top level is will apply to all sub-directories unless explicity reversed.'' == How can I control what users can do with .htaccess files? == @@ -119, +129 @@ Try putting garbage in it. If it is being read, you'll get an Internal Server Error when accessing that URL. If it is being read, continue to ["ScratchPad/htaccessGotchas"] to find more about what might be wrong. - = How do I use .htaccess files? = - - Implementation of .htaccess files is universal across the Internet. Many manuals are available online. You can visit your favorite search engine and search for 'htaccess', and you'll probably find a nice tutorial just like [http://httpd.apache.org/docs/2.0/howto/htaccess.html this one]! Once you have grasped the basic concepts, it would definately help you to refer to the many examples available here on the wiki, there is also a great [http://www.askapache.com/2006/htaccess/htaccesselite-ultimate-htaccess-article.html htaccess Code Snippet Article] full of the most commonly requested htaccess code examples. - - - - == How can I create a plain text file for .htaccess? == - - You can do it by sshing in to yourdomain.com and using pico, a user-friendly text editor. All the commands for its use appear at the bottom of the page (^ means ''press the Control key.'') Just change to the directory in which you want to use .htaccess, and type "pico .htaccess" to get started with a blank .htaccess file. -
