.htaccess tutorial
.htaccess file
provide a way to make config changes on a per-directory.
A file, containing one or more guidelines settings, it is placed in a particular directory, and the directives apply to that directory and all its subsequent subdirectories.
Notice:
For example, if you prefer that the file is called .htacc
then you could add the following line to your server's config file httpd.conf:
If a policy is allowed in a .htaccess
file, the documentation for this guideline will contain a section Override, specifying that value must be in AllowOverride
for this directive is permitted.
So you must at least have AllowOverride FileInfo
to accept that this directive is in the .htaccess
If you are uncertain whether a guideline in particular is accepted in a .htaccess
file, look at the documentation for this policy, and check the line for Context ".htaccess".
You can use the user authentication settings in the config file's main server, and that is, in fact, the most appropriate way of doing things.
This is particularly true, for example, in cases where providers are providing multiple sites for users in just a machine, and want their users to change their settings.
Any settings you consider adding in
a .htaccess,
can be effectively placed in a section
in the main config file from your server.
There are two main reasons to avoid the
use of .htaccess.
Moreover, the .htaccess
file is loaded each time a document is required.
See the section as the directives are applied. So if a file from one directory /webroot/htdocs/folder
is required, then Apache must look for the following files:
/.htaccess
/webroot/.htaccess
/webroot/htdocs/.htaccess
/webroot/htdocs/folder/.htaccess
Notice that this will only be the case if the .htaccess files
are entitled and allowed access to /, which is not normally the case.
Specify exactly what you set in the directive AllowOverride,
and direct them to the relevant documentation, will spare you a lot of confusion later.
Notice that is exactly equivalent place the .htaccess file
in a directory /webroot/htdocs/folder
containing a guideline, and add the same directive in a section Directory
in the config of your main server
Archive .htaccess
in /root/htdocs/public_html
Content of a .htaccess file in /www/htdocs/public_html
AddType application/x-httpd-php .php
Section of your httpd.conf
However, adding it to your server's config file will result in a lower loss of performance, as far as the setup is loaded at boot from the server, instead of a file that all that is required.
The use of .htaccess
can be completely disabled, adjusting the directive AllowOverride
to none
These, in turn, can be overridden by its directives guidelines further up, or in the main config file from the server.
Example:
In the directory
/root/htdocs/public_html1
we have an apache .htaccess
containing the following:
Notice: you must have "AllowOverride Options"
to allow use of the directive "Options"
in the .htaccess
In the directory
/root/htdocs/public_html1/example2
we have an apache .htaccess
containing:
Because of this second .htaccess
file in the directory
/root/htdocs/public_html1/example2,
to run CGI scripts is not allowed, because only Includes Options
is in effect, which completely override any other adjustments previously configured.
See the discussion above about when you should and when you should not use the .htaccess file.
That said, if you still believe you need to use a .htaccess
file, the config below probably will for you.
Content of
a .htaccess
file:
Basic AuthType
AuthName "Hacking Attempt"
AuthUserFile /webroot/private-dir/.htpasswd
AuthGroupFile /webroot/private-dir/.htgroup
Require Group admins
Notice that AllowOverride AuthConfig
must be enabled so that these guidelines take effect.
Please see the authorization tutorial for a more complete discussion of authentication and authorization in .htaccess files.
This can be done with the following directives for setting, placed in a .htaccess
file in the desired:
Options +Includes
AddType text/html shtml
AddHandler server-parsed shtml
Notice that both AllowOverride Options
and AllowOverride FileInfo
must be empowered to these guidelines have effect.
Check out the SSI tutorial on apache for a more complete discussion of server-side includes.
This can be implemented with the following settings:
Options +ExecCGI
AddHandler cgi-script cgi pl
Alternatively, if you want all the files in a given directory, as CGI programs, it can be done with the following config:
Options +ExecCGI
SetHandler cgi-script
Notice that both AllowOverride Options and AllowOverride FileInfo must
be enabled so that these directives have any effect.
Please see the apache cgi tutorial of CGI tutorial for a more complete discussion of CGI programming and config.
When you add guidelines config to a .htaccess
file and not get the desired effect, there are a number of points that may be wrong.
If not generated any error from the server, you certainly have AllowOverride None
qualified.
Alternatively, it can accuse you of syntax errors will be corrected.
- Authentication
- The positive identification of an entity such as a network server, a client, or user.
HTTPD Apache Docs Link: Authentication, Authorization and Access Control - Access Control
- In the context of Apache normally means restricting access to certain domains
HTTPD Apache Docs Link: Authentication, Authorization and Access Control - Algorithm
- The algorithms are called to encrypt usually encryption algorithms
- apacheextensiontool (apxs)
- It is a script written in Perl that helps compile the source code for some modules to become Dynamic Shared Objects (DSO s) and helps to be installed on the Apache Web server.
HTTPD Apache Docs Link: Pages Help: apxs - Certificate
- Network entities verify signatures using certificates of BC.
Apache SSL / TLS - certificationauthority (ca)
- Other entities network can verify the signature to verify that a Certificate Authority had authenticated the holder of the certificate.
Apache SSL / TLS - certificatsigningrequest (csr)
- Once the CSR is signed, it becomes a genuine certificate.
Apache SSL / TLS - Encryption Algorithm
- Examples of these algorithms are DES, IDEA, RC4, and so on.
Apache SSL / TLS - Text encryption
- The result of having applied to a text unencrypted an encryption algorithm.
HTTPD Apache Docs Link: SSL / TLS - Common Gateway Interface (CGI)
- This interface was originally defined by the NCSA but there is also a draft RFC.
HTTPD Apache Docs Link: Dynamic Content with CGI - Configuration Directives
- HTTPD Apache Docs Link: Directives
- Configuration File
- A text file containing directives that control the configuration of Apache.
HTTPD Apache Docs Link: Configuration Files - CONNECT
- It can be used to encapsulate other protocols, such as SSL protocol.
- Context
- An area in the configuration files where they are allowed certain types of directives.
HTTPD Apache Docs Link: Terms used to describe the Apache Directives - Digital Signature
- Only the public key can decrypt the CAs signature, verifying that the CA has authenticated the network entity owns the certificate.
Apache SSL / TLS - Directive
- The directives are in the Configuration File
HTTPD Apache Docs Link: Index Directives - dynamicsharedobject (dso)
- The modules compiled separately to Apache httpd binary can be loaded as required.
HTTPD Apache Docs Link: Support Dynamic Shared Object - environmentvariable (env-variable)
- Apache also contains internal variables that are referred to as environment variables, but which are stored in the internal structures of Apache, rather than in the shell environment.
HTTPD Apache Docs Link: Environment Variables Apache - Export
- The cryptographic software Export is limited to a small key, so that the ciphertext that is achieved with it, can desencriptarse by brute force.
Apache SSL / TLS - Filter
- For example, the output filter
INCLUDES
processes documents for Server Side Includes.
HTTPD Apache Docs Link: Filters - fully-qualifieddomain-name (fqdn)
For
example, www is a hostname, example.com
is a domain name, and www.example.com
is a fully qualified domain name. - Handler
- For example, the handler
cgi-script
designates files to be processed as CGI.
HTTPD Apache Docs Link: Using Apache Handler -
- Part of the petition and HTTP response that is sent before the actual content, which contains metadata describing the content.
- .htaccess
- Despite its name, this file can contain any type of guidelines, directives not only access control.
HTTPD Apache Docs Link: Configuration Files - Httpd.conf
- The default location is
/ usr/local/apache2/conf/httpd.conf,
but can move using configuration options when compiling or start Apache.
HTTPD Apache Docs Link: Configuration Files - hypertexttransferprotocol (http)
- Apache implements version 1.1 of this protocol, which is referred to as HTTP/1.1 and defined by RFC 2616.
- HTTPS
- Actually HTTP over SSL.
Apache SSL / TLS - Method
- Some of the methods diponibles HTTP
are
GET, POST
and PUT.
- Message Digest
- A hash of a message, which can be used to verify that the content of the message has not been altered during transmission.
Apache SSL / TLS - MIME-type
- In HTTP, the mime type is transmitted in the headwaters of the
Content Type.
HTTPD Apache Docs Link: mod_mime - Module
- These modules are called modules third.
See Table Module - modulemagicnumber (mmn)
- If you change the magic number of module, all the modules of others must be at least recompiled, and sometimes even need to be slight modifications to run with the new version of Apache
- OpenSSL
- The Open Source toolkit for SSL / TLS
See http://www.openssl.org/ - Pass Phrase
- Usually its just the key encryption / decryption algorithms used by encryption.
Apache SSL / TLS - Plaintext
- The unencrypted text.
- Private Key
- The key secret of a Public Key Cryptography system, used to decrypt incoming messages and sign outgoing.
Apache SSL / TLS - Proxy
- If multiple clients requesting the same content, the proxy serves content from its cache, instead of asking every time they need to source server, reducing this turnaround time.
HTTPD Apache Docs Link: mod_proxy - Key Publish
- The key publicly available in a Public Key Cryptography system, which is used to encrypt messages intended for its owner and to decrypt signatures made by its owner.
Apache SSL / TLS - Criptográfia Public Key
- Also called Asymmetric Cryptography.
Apache SSL / TLS - regularexpresion (regex)
- One way to describe a standard text-for example, "all words that begin with the letter" A "or" all the phone numbers that contain 10 digits "or even" All sentences between commas, and they do not contain any Q letter. "Regular Expressions in Apache are useful. Uses Apache Perl Compatible Regular Expression thanks to the PCRE library.
- Reverse Proxy
- It is useful to hide the true source server to the client for security, or for load balancing.
- Secure Sockets Layer (SSL)
- Its implementation is more popular HTTPS, the Hypertext Transfer Protocol (HTTP) over SSL.
Apache SSL / TLS - Server Side Includes (SSI)
- A technique for embedding process directives in HTML files.
HTTPD Apache Docs Link: Introduction to Server Side Includes - Session
- Information context of a communication in general.
- SSLeay
- The original implementation of the library SSL / TLS developed by Eric A. Young
- Symmetric Cryptography
- The study and application of encryption algorithms that use a single secret key for both encryption to decrypt.
Apache SSL / TLS - Tarball
- The Apache distributions are stored in compressed files with tar or pkzip.
- transportlayersecurity (tls)
- Version 1 of TLS is almost identical to the version 3 SSL.
Apache SSL / TLS - uniformresourcelocator (url)
- A URL for this page is
http://httpd.apache.org/docs/trunk/glossary.html.
- uniformresourceidentifier (URI)
- URIs in use world-wide web are commonly referred to as URLs.
- Virtual Hosting
- They are serving different websites with a single entity Apache. Hosting virtual IPs difference between websites based on their IP addresses, while the name-based virtual hosting uses only the name of the host and thus can accommodate many websites with the same IP address.
HTTPD Apache Docs Link: Documentation Hosting Virtual Apache - X.509
- A certificate authentication scheme recommended by the International Telecommunication Union (ITU-T) which is used for authentication SSL / TLS.
Apache SSL / TLS