.htaccess

Htaccess. (English hypertext access " hypertext access " ) is a configuration file in the directory-specific settings on NCSA -compliant web servers (eg Apache) can be made.

For example, there can be an access protection via HTTP authentication for a directory or individual files set up. However, error pages or internal links (see rewrite engine ) can be set here on, without having to restart the server:. Changes in the htaccess file will take effect immediately, as these are evaluated on every request to the web server. In these files, settings affect how in central configuration files (eg httpd.conf). They apply only to the directory where they are stored, as well as all subdirectories. They can be overridden again in the subdirectories.

Purpose

Access Protection

If you want access to a directory by querying log data protected ( here / var / www / html ), in this directory, create a. Htaccess file is created with the following content.

AuthType Basic AuthName "Title of password protection " AuthUserFile / var / www / html / .htpasswd Require valid-user This AuthUserFile points to a file, the user name and password in the form username: contains hash. This content can be generated for example with the htpasswd tool or with an online generator.

$ Htpasswd -nb TheName dasPasswort TheName: $ apr1 $ m0OaZVp0 $ 9OHApAf65z24vNUZts8Zz1 The hash functions are MD5, bcrypt, crypt and SHA to choose from. If necessary. the password is hashed together with a salt randomly selected, which means that even identical passwords get different password hashes.

Request Redirection

Does the web server a module for internal rewriting a URL, so redirections can be defined in the. Htaccess file. The following example forces a redirect to http://www.example.com, if this address was not also part of the request.

RewriteCond % { HTTP_HOST }! ^ Www.example.com $ [ NC] RewriteRule ^ (. * ) $ Http://www.example.com/ $ 1 [L, R = 301 ] Web Links

  • Extensive explanation and password generator at SELFHTML
  • . htaccess tutorial (english) in the documentation of Apache 2.2
  • . htaccess tutorial (english) in the documentation of Apache 2.4 ( there were new features for. htaccess added)
  • PHP script " htedit " at SourceForge
  • Apache project
de