SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: .htaccess woes

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Glasgow
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess woes

    I've been using the .htaccess file I do on all of my projects
    Code:
        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?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Stevie,

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

    Code:
        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]
    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).
    [/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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •