Monday, April 15, 2013

Configuration for an HTTP Server, Directives

Apache HTTP Server, commonly known as Apache, is the most popular web server software that uses directives for its configuration which can be written into a .htaccess (hypertext access) hidden file, it's hidden for it is started with a "." dot. As directives are used to configure the most popular HTTP server, many other HTTP servers uses the same way to configure their systems too. One of the popular use of an HTTP server is to modifies a web Uniform Resource Locator's appearance which is called “URL Rewriting” and to redirect a web address to another URL, which called “URL Redirecting.” The abbreviation "HTTP" is stands for Hypertext Transfer Protocol. A web server that can modifies URL's appearance is often called as HTTP server instead of web server.
  1. URL Rewriting: Actually, the software that remapping the URL into another URL is called as rewrite engine which is basically runs on a web server. If the URL is rewriting into a different page, even you're viewing the page at that URL, you'll see the other page where it rewriting, even if it exist or not. Here's an example of .htaccess source' directives for configuring the mod_rewrite of Apache HTTP Server to rewrite:
    URL Example:
    1. http://www.example.com/index
    2. http://www.example.com/test
    3. http://www.example.com/anything
    .htaccess Directives' Sample:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([a-zA-Z0-9_-]+)/?$ /page.php?file=$1 [NC,QSA]
    Where Example's URLs are Remapping:
  2. URL Redirecting: The mod_rewrite of Apache HTTP Server can also perform to redirect the specific or dynamic URL that you want into another specific or dynamic URL, even from the other domain until it's under control of your Apache, it can be redirected. It means, when viewers visit the URL that redirecting to other page, they'll be redirected to another URL according to rule. And these configuration directives for .htaccess file is to URL redirect:
    URL Example:
    1. http://example.com
    2. http://example.com/anything.html
    3. http://test.example.com
    4. http://test.example.com/anything.html
    .htaccess Directives' Sample:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R,NE]
    Where Example's URLs are Redirecting:
Our topic is not how to remap a web URL's appearance, nor to redirect it, but about configuration directives! One of a web server that uses configuration directives is nginx (pronounced as “engine x”). But not all HTTP servers uses directives as their configurations, such Internet Information Services which uses XML tags for their configuration.

No comments:

Post a Comment

You can use some HTML tags, such as <b>, <i> and <a> tags, but please do not spam.