Litespeed .htaccess performance question

Discussion in 'General' started by tseven, Apr 24, 2008.

  1. tseven

    tseven New Member

    Is there an advantage of specifying my rewrite rules direclty in the vhost config of litespeed rather than in a .htaccess file?

    Perhaps it's quicker, or gets cached etc?

    Thanks
  2. mistwang

    mistwang LiteSpeed Staff

    Yes, it is always a good idea to avoid using .htaccess.
  3. tseven

    tseven New Member

    That's what I thought.

    I'm trying to run these rewrites for my drupal 5.7 site and after turning on logging I think I've found the problem.

    The rewrite:
    Code:
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    The error is:
    Code:
    [REWRITE] Source URI: '/providers' => Result URI: 'index.php?q=/providers'
    It would apear that it's grabbing the entire string of '/providers' with the forward slash, when it should only be 'providers'.

    This is the exact code which works when placed in the .htacess file:
    Code:
    <Directory /www/domain.com/public>
       RewriteEngine on
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </Directory>
    
    I've tried it with and without the <directory> part,.. with and without the RewriteBase on.

    I get this error in firefox:
    Code:
    The page isn't redirecting properly
    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    Any help would be greatly appreciated.

    Thanks
  4. sh0ck

    sh0ck New Member

    Not sure but the regex you are using will always take the entire strings its passed from begining( ^ ) to end( $ ). Since not using an htaccess seems to be adding a / try maybe this regex which will only trap anything AFTER the / and insert it in variable $1.


    Code:
    RewriteRule ^/(.*)$ index.php?q=$1 [L,QSA]

    Timothy J. Biggs
    --
    Senior Vice President / CIO

    BLUE GRAVITY COMMUNICATIONS, INC.
    3495 Haddonfield Rd. Suite 6
    Pennsauken, NJ 08109
    Toll Free: 1-877-8 HOSTING
    Tel: (856)662-9100, Fax: (856) 662-9101
    Email: tim@bluegravity.com
    http://www.bluegravity.com
  5. mistwang

    mistwang LiteSpeed Staff

    The URI used for a rewrite rule in .htaccess is different from the rewrite rule configured at vhost level. Basically, the rewrite base will be removed from the URI before matches the URI with a rewrite rules in .htaccess.
    You need to change the rewrite rule according like what Timothy suggested when you move a rewrite rule form .htaccess to vhost level.
  6. tseven

    tseven New Member

    Thank you sh0ck, that was solution, everything works well now.

    Cheers :)

Share This Page