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: fixed url, and removed over use of quotation marks ------------------------------------------------------------------------------ (!) This document should be used to draft a new version of the [http://httpd.apache.org/docs/trunk/howto/htaccess.html official httpd howto docs] (!) + ---- + - '''The use of .htaccess files is strongly discouraged as they can have a detrimental effect on server performance. Please use it only when strictly needed.''' + '''The use of .htaccess files is strongly discouraged as they can have a detrimental effect on server performance. Only use them when strictly necessary.''' == What's .htaccess files purpose? == - The purpose of .htaccess files is to provide a means to configure HTTPd to users that cannot modify the main configuration file (usually httpd.conf, see DistrosDefaultLayout). + 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"]]). == .htaccess myths == === .htaccess files mean password protection === - No, .htaccess files can be used to provide password protection the same way main configuration files can be used to provide + No, .htaccess files can be used to provide password protection the same way main configuration files can be used to provide password protection, nothing special about .htaccess here. - password protection, nothing special about .htaccess here. == When should I use .htaccess files? == @@ -24, +25 @@ === 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! - 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 (BUT PLEASE DON'T!), or, you could create a + 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''' {{{ - <Directory "/var/www/html/vhost-1> + <Directory /var/www/html/vhost-1> AuthType Basic AuthName "Authentication Required" - AuthUserFile "/etc/htpasswd/vhost-1/.htpasswd" + AuthUserFile /etc/htpasswd/vhost-1/.htpasswd Require valid-user Order allow,deny @@ -47, +47 @@ {{{ AuthType Basic AuthName "Authentication Required" - AuthUserFile "/etc/htpasswd/vhost-1/.htpasswd" + AuthUserFile /etc/htpasswd/vhost-1/.htpasswd Require valid-user Order allow,deny @@ -67, +67 @@ == How can I create a new .htaccess file? == Use your favourite editor to create a .htaccess file in the folder where you want it to take affect. - + Making sure that the file can be read by the uid Apache runs as. == What can I do with my .htaccess file? == + You are restricted from two fronts, what the administrator chooses to enable, and what Apache allows. To check the first one, contact your administrator (or hosting provider, or just try), to check the second one, find the directive you want to use in the documentation, and see the Context: section. If it says .htaccess, then it can be used, given that the admininstrator gave - You are restricted from two fronts, what the administrator chose to enable, and what Apache allows. To check the first one, - contact your administrator (or hosting provider, or just try), to check the second one, find the directive you want to use in - the documentation, and see the Context: section. If it says .htaccess, then it can be used, given that the admininstrator gave you access to that. == 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''' ---- +
