You are Here: FAQ ->Scripting and Programming Languages->Configuring Apache Webserver using .htaccess->Article #4


WebHosting 5.0 This article is for 1&1 Linux WebHosting only.


Modifying Apache Webserver configuration



You cannot modify the "httpd.conf" file of Apache Webserver in our Shared
hosting and Managed Server packages.


But you can adjust the Apache webserver properties to your needs by editing a
control file. You can list various commands in this file enabling you to control
access to a directory, to have custom error pages, to list the content of
directories, etc.

The control file ".htaccess" can be placed in various directories of your site.
Please note that commands in a .htaccess file effect ALL subdirectories as well!

If you want the changes to be applied to your entire webspace all you need to do is
place one .htaccess files containing the configuration into the maindirectory of
your space (/.)

The following list is a selection of commands which can be used in a ".htaccess" file:
Command Description
ErrorDocument Define your own custom error pages
AddType Assign a MIME-Type to a file ending
RewriteEngine Activate mod_rewrite module
Allow/Deny Host or IP based access control
FilesMatch File based access control
AuthType "Basic" password check
Redirect Redirection to another page or site
Options (de)activate index, symbolic links, etc.


You can find the entire Apache documentation at www.apache.org

A few examples:

# activates directory indexing
# (disabled by default due to security reasons)
#
Options +Indexes

# deactivates "spell checking" (example: if enabled,
# http://domain.com/file1.html will be turned into
# http://domain.com/file.html, in case file1.html does not
# exist and file.html exists)
#
CheckSpelling off

# allow other file extensions for CGI scripts:
#
AddHandler cgi-script .cgi .asp

# allow other file extensions for SSI (Server Side Include) scripts:
#
AddType text/x-server-parsed-html .shtm .shtml .htm .html

# Example for a rewrite rule:
# (turns http://domain.com/xyz.html into http://domain.com/index.php?xyz)
#
RewriteEngine on
RewriteBase /
RewriteRule ^([a-z]+)\.html$ /index.php?$1 [R,L]

# allows the Web server to provide ".inc" files for view / download
# (disabled by default due to security reasons)
#
<FilesMatch "\.inc$">
order deny,allow
allow from all
</FilesMatch>

#parsing PHP in html files
#
AddType x-mapp-php4 .html .htm

#parsing .php as .php4 files
#
AddType x-mapp-php4 .php3

#parse files that have no extensions as PHP scripts
#This must be done for each file that needs to be parsed
<Files filename_to_be_parsed>
ForceType x-mapp-php4
</Files>

You can find more information at http://www.apache.org/docs/



Disclaimer: 1&1 provides the scripts and related information on this page as a courtesy, subject to 1&1's General Terms and Conditions of Service (the "GT&C"). As set forth in more detail in the GT&C, the scripts and information are provided "as-is", without any warranty, and 1&1 is not liable for any damages resulting from your use of the scripts or information.



Print Article
How useful was this article?
(From 5 = Very Useful to 1 = Not useful at all):
1 2 3 4 5