Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My .htaccess file is in the root directory of my website, and I narrowed down a problem to the single line of code 'RewriteEngine on'. How do I know it's this piece of code? Because I deleted the entire .htaccess file except for 'RewriteEngine on' as a test...and my CGI application still broke.

If anyone has any idea why the 'RewriteEngine on' line decides to break the CGI application all on it's own I'd love to hear it! Thanks,


PS - Just in case you're interested, the piece of code that I want to get working is to help consolidate all domains into a single domain (the line breaks are there simply to make it easier to read):

RewriteEngine on

RewriteCond %{HTTP_HOST} ^$ [NC]

RewriteRule ^(.*)$$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html

RewriteRule (.*) [R=301,L]

share|improve this question

migrated from Dec 23 '09 at 3:56

This question came from our site for professional and enthusiast programmers.

Chances are that mod_rewrite is not currently enabled in your Apache configuration (usually in httpd.conf).

If it is enabled, it would look something like this:

# For Unix-like OSes
LoadModule rewrite_module modules/


# For Windows
LoadModule rewrite_module modules/mod_rewrite.dll

as well as

# For both
AddModule mod_rewrite.c

The AddModule line may not be necessary in Apache 2.0/2.2.

Some OSes place Apache module loaders in another directory. On Debian and Ubuntu Linuxes, configuration files for installed modules are in /etc/apache2/modules-available, and can be activated with a2enmod modulename; in this case a2enmod rewrite.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.