Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2002
    Location
    Yuba City, CA
    Posts
    358

    Configuring htaccess question

    Hi,

    I took over the web site of a company where the previous developer had put in a rewrite rule in the .htaccess that looks like this:

    RewriteEngine on
    RewriteRule .* index.php [L]

    So, now whenever we try to use a .html file, it rewrites it to a .php file. However, this is really only needed for the main web site which is OsCommerce based. When I try to view the stats directory, I get a 404 error because all the files in there are .html and not .php.

    I would like to set this up so that it does not apply to the 'stats' directory which is created by webalizer and builds .html file.

    How can I change this rule to not apply to the '/stats' directory off of the root of the web site?
    David
    Beenanza, LLC

  2. Hi,

    The following should work.

    Code:
    Rewrite Engine on
    RewriteCond %{REQUEST_URI} !^/stats
    RewriteRule .* index.php [L]
    Phil.
    Philip Reynolds
    Hosting365
    Value for money dedicated servers
    at Rack365 - http://rack365.ie/

  3. #3
    Join Date
    Jan 2002
    Location
    Yuba City, CA
    Posts
    358
    That sure did it Phil. Thanks for your help!!
    David
    Beenanza, LLC

  4. #4
    Taking out "stats" directory out of rewrite should also do the trick. That's just an alternative solution to Phil's but I will mention it anyway.

    Code:
    RewriteEngine On
    RewriteRule ^/stats - [L]
    RewriteRule .* index.php [L]

  5. #5
    Join Date
    Jan 2002
    Location
    Yuba City, CA
    Posts
    358
    Thanks maxymizer. Good to know all my options.
    David
    Beenanza, LLC

  6. Yup, definitely possible, but not optimal:


    1) Slow due to the way mod_rewrite processes URL's. The URL's never get passed into the core engine for matching with RewriteCond.

    2) Readability is reduced.
    Philip Reynolds
    Hosting365
    Value for money dedicated servers
    at Rack365 - http://rack365.ie/

  7. #7
    Actually, if URL doesn't get passed to matching engine how can that be slower?
    Also, readability reduction? Can you pinpoint what's less readable in my example? I'm really interrested (note: I have no desire to flame whatsoever so I kindly ask you to show me what you meant since both examples are at the same level of readability to me).

Posting Permissions

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