.htaccess woes

I’ve been using the .htaccess file I do on all of my projects

    AcceptPathInfo On

    Options -Indexes

    <IfModule mod_rewrite.c>
    RewriteEngine On

    # Looks for files and directories that do not exist
    # and provide the segments to the index.php file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^/index.php
    RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>  

I know that mod_rewrite is installed because there’s a current .htaccess file on this server that works (some basic redirects) but mine seems to render a 500 issue.

Why would that be?

Stevie,

A 500 error is generally evidence of a typo in the .htaccess - at least, it’s an unrecognized directive.

    AcceptPathInfo On

    Options -Indexes

    <IfModule mod_rewrite.c>
    RewriteEngine On

    # Looks for files and directories that do not exist
    # and provide the segments to the index.php file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^/index.php
    RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>  

Looking at your code:

  1. I’m not familiar with the AcceptPathInfo directive.

  2. Nothing personal but … [rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/rant 4]

  3. Your third RewriteCond can only be matched on an Apache 1.x server (with the hardcoded leading /). IMHO, remove the / or, at the very least, make it optional.

  4. Your fourth RewriteCond uses an unescaped . prior to the series of acceptable file extensions. That means ANY CHARACTER, not just the dot character so I’d recommend escaping that . (i.e., ‘.’ => ‘\.’). Hmmm, same with the . in index.php in RewriteCond #3.

With all those comments, though, I do not see a definitive typo so the process to go through would be to comment out, line-by-line, and restore to see whether the 500 error persists or not (start with the AcceptPathInfo on line).

Regards,

DK