Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 127.0.1.1 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 127.0.1.1 for ServerName
josiah@BOX-OF-DOOOM:~$ 

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>

  <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
  </IfModule>
  <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Expires "Thu, 15 Apr 2011 20:00:00 GMT"
  </FilesMatch>

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.

edit:

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:
  core.c
  mod_log_config.c
  mod_logio.c
  prefork.c
  http_core.c
  mod_so.c
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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

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

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
add comment

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
</Directory>

after this block:

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

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/mod_rewrite.so

Reload one more time the server.

share|improve this answer
add comment

Your Answer

 
discard

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.