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 VinkoVrsalovic: http://wiki.apache.org/httpd/ScratchPad/htaccess ------------------------------------------------------------------------------ == What's .htaccess files purpose? == - The purpose of an .htaccess file is to provide a means to configure HTTPd for users that cannot modify the main configuration file (usually httpd.conf, see [["Info/DistrosDefaultLayout"]]). + The purpose of an .htaccess file is to provide a means to configure Apache for users that cannot modify the main configuration file (usually httpd.conf, see [["Info/DistrosDefaultLayout"]]). == .htaccess myths == @@ -26, +26 @@ Well, it might be, but you can use the Include directive to alleviate that if it really bothers you! Let's suppose you dislike huge config files and that, for instance, you want to provide password authentication for all your virtual hosts. You could put a .htaccess in the root of each virtual host, or you could create a - directory within the tree of apache's config files and create a config file per vhost with the proper directives, say /usr/local/apache2/conf/vhosts-protection. Then, in httpd.conf you can write Include /usr/local/apache2/conf/vhosts-protection/*.conf for all those directives to take effect. + directory within the tree of apache's config files and create a config file per vhost with the proper directives, say /usr/local/apache2/conf/vhosts-protection. Then, in httpd.conf you can write + {{{ + Include /usr/local/apache2/conf/vhosts-protection/*.conf + }}} + for all those directives to take effect. '''/usr/local/apache2/cont/vhosts-protection/vhost-1.conf''' {{{ @@ -41, +45 @@ </Directory> }}} + And so on for the rest of your virtual hosts. + - And so on. Now let's suppose you really must use .htaccess files, the .htaccess file should be located in /var/www/html/vhost-1/ and it should read like: + Now let's suppose you really must use .htaccess files, the .htaccess file should be located in /var/www/html/vhost-1/ and it should read like: '''/var/www/html/vhost-1/.htaccess''' {{{ @@ -54, +60 @@ Allow from all }}} - As you can see, .htaccess files are restricted to the directory they're placed in, and thus you can think of .htaccess files as adding dynamically to Apache configuration a <Directory /path/to/.htaccess> .htaccess content </Directory> + As you can see, .htaccess files are restricted to the directory they're placed in, and thus you can think of .htaccess files as adding dynamically to Apache configuration a + {{{ + <Directory /path/to/.htaccess> + #.htaccess content goes here + </Directory> + }}} == How do I use .htaccess files? == @@ -75, +86 @@ == How do I troubleshoot my .htaccess file? == - ---- /!\ '''Edit conflict - other version:''' ---- 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 see ["ScratchPad/htaccessGotchas"] to find more about what can be going wrong. - ---- /!\ '''Edit conflict - your version:''' ---- - 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 see ["htaccessGotchas"] to find more about what can be going wrong. - - ---- /!\ '''End of edit conflict''' ---- -
