Blog Archive

Apache HTTP Server sample Configuration file - httpd.conf

Configure SSL on iSeries Apache Server

#Load the SSL module program 

# Listen on port 443 for your IP address 

#Create virtual host for port 443 and set the proper SSLAppName to which the certificate is associated
  SSLEngine On                            
  SSLClientAuth None                      
  SetEnv HTTPS_PORT 443         

Apache permanent Redirect

Redirect 301 /foo


Redirect permanent /foo

Apache error document page

Create your custom page such as error404.html and then reference it in the config file as shown below
ErrorDocument 404 

Apache prevent directory listing

Options -Indexes

Apache Maps URLs to filesystem locations

Alias /icons/ /usr/local/apache/icons/

This directive is equivalent to Alias, but makes use of standard regular expressions, instead of simple prefix matching. The supplied regular expression is matched against the URL-path, and if it matches, the server will substitute any parenthesized matches into the given string and use it as a filename. For example, to activate the /icons directory, one might use:
AliasMatch ^/icons(.*) /usr/local/apache/icons$1 

Apache mod rewrite

RewriteRule Pattern Substitution [flags]
RewriteEngine On                      
RewriteRule .* - [F]           
RewriteRule /product/([0-9]+)  /product?item=$1 [NC,PT]

When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.

Consider the following rule:

RewriteRule /pages/(.+) /page.php?page=$1 [QSA]

With the [QSA] flag, a request for /pages/123?one=two will be mapped to /page.php?page=123&one=two. Without the [QSA] flag, that same request will be mapped to /page.php?page=123 - that is, the existing query string will be discarded.

Apache Name-based Virtual Host Support

Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. Name-based virtual hosting also eases the demand for scarce IP addresses. Therefore you should use name-based virtual hosting unless there is a specific reason to choose IP-based virtual hosting. Some reasons why you might consider using IP-based virtual hosting:

  • Some ancient clients are not compatible with name-based virtual hosting. For name-based virtual hosting to work, the client must send the HTTP Host header. This is required by HTTP/1.1, and is implemented by all modern HTTP/1.0 browsers as an extension. If you need to support obsolete clients and still use name-based virtual hosting, a possible technique is discussed at the end of this document.
  • Name-based virtual hosting cannot be used with SSL secure servers because of the nature of the SSL protocol.
  • Some operating systems and network equipment implement bandwidth management techniques that cannot differentiate between hosts unless they are on separate IP addresses.

   DocumentRoot /www/as400/htdocs            
   DirectoryIndex as400.html     

   DocumentRoot /www/iSeries/htdocs           
   DirectoryIndex iSeries.html