Tag Archives: RewriteRule

Redirect from base URL using Apache HTTP Server

What I was trying to accomplish was quite simple—redirection from the base URL (e.g. http://webjawns.com) to a specified path within the same domain.  Even with a lot of experience, one can easily fall prey to assumptions about proper Redirect usage.  Instead of working as expected, the code below caused the repeated concatenation of the destination URL term (“tools” in this example).

# The WRONG way to redirect from the base URL
Redirect / /tools
Redirect / http://webjawns.com/tools

Traditionally, the Redirect directive is used as a simple method of redirection from one page to another. In the following example, the HTTP server will redirect the end user from old-index.html to new-index.html.

# Redirect from old-index.html to new-index.html
Redirect /old-index.html /new-index.html

If there is a way to use a Redirect directive to accomplish redirection from the base URL, I have not figured it out. To solve this problem, I used the rewrite engine, which works flawlessly.

RewriteEngine On
RewriteRule ^/$ http://tools.caffeinatedaviator.com/xgoflight [R=302,L]