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

I feel like I've done everything right:

josiah@BOX-OF-DOOOM:~$ sudo apache2ctl start
apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
josiah@BOX-OF-DOOOM:~$ sudo a2enmod rewrite
Module rewrite already enabled
josiah@BOX-OF-DOOOM:~$ sudo apache2ctl restart
apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName

Then in my .htaccess (this is for CodeIgniter):

  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTPS} !=on
    RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

  <IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
  <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Expires "Thu, 15 Apr 2011 20:00:00 GMT"

And yet navigating to something without explicitly entering "index.php" fails to load. Any ideas?

This is supposed to take any url sent (/whatever/the/url/was) to apache and redirect to index.php/whatever/the/url/was. If I enter index.php/whatever/the/url/was, then it works great, but if I remove index.php, it fails.


Also, mod_rewrite doesn't seem to be enabled, even though a2enmod says it is (as I pasted above)

josiah@BOX-OF-DOOOM:~$ sudo apache2ctl -l
[sudo] password for josiah: 
Compiled in modules:
share|improve this question
up vote 3 down vote accepted

In your VirtualHost config, or in your Directory block do something like:

<Directory /path/to/webroot/>
AllowOverride all

a2enmod loads modules, those aren't compiled into apache, but, are dynamically linked.

share|improve this answer
ty, that's what I needed. I figured it out right as you posted XD. – Josiah Kiehl Jun 22 '10 at 19:35

If you put some .htaccess file in your server and doesn’t work as expected, maybe you are trying to install a Drupal site or to set Zend Framework, follow this steps.

Find your site virtual host file or edit the 000-default in the /etc/apache2/sites-enabled/

Add this lines:

<Directory /var/www/mysite/>
AllowOverride all

after this block:

<Directory />
Options FollowSymLinks
AllowOverride None

Reload the server with

sudo /etc/init.d/apache2 reload

This should be done after each modification.

If you get a 500 type of error trying to view your site don’t panic!

This happens because the rewrite module doesn’t come enabled by default for security reasons.

Create a new file called rewrite.conf in /etc/apache2/mods-enabled in the file put this line

LoadModule rewrite_module /usr/lib/apache2/modules/

Reload one more time the server.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.