Tag Archives: .htaccess

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]

How Zend Server CE breaks WordPress Permalinks and how to fix it

Recently, I switched to Zend Server CE from a manually installed AMP package (Apache/MySQL/PHP) to make use of Zend’s lightweight environment and easy install package. In doing this, I found that it broke the permalinks associated with WordPress.  Despite mod_rewrite being enabled, and the “Pretty Permalinks” code being in the .htaccess file, it still didn’t work.

404 Error

To fix this problem do the following:

  1. Open up httpd.conf.  (On Windows, the default location of this file is C:Program FilesZendApache2conf.)
  2. Find the line with <Directory />.
  3. Make sure +FollowSymLinks is present on the Options line.  (i.e. Options +FollowSymLinks)
  4. Change AllowOverride None to AllowOverride All.
  5. Restart Apache.

AllowOverride controls how .htaccess files are used.  When AllowOverride is set to None, users cannot override the configurations set in httpd.conf for particular directories.  While the .htaccess in this client’s WordPress directory was correct, Apache wasn’t allowing it to override the default settings as stated in httpd.conf.  It is definitely worth it to learn more about how to configure Apache so that you can have a secure and well-performing environment, especially if a lot of developers work on the same production server.

If you have similar experience, we would love to hear what you have to say.  Perhaps it will save someone else a minute or even a few hours.