PDA

View Full Version : Litespeed .htaccess performance question


tseven
04-24-2008, 01:39 AM
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

mistwang
04-24-2008, 02:20 PM
Yes, it is always a good idea to avoid using .htaccess.

tseven
04-24-2008, 02:30 PM
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:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

The error is:
[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:
<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:
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

sh0ck
04-24-2008, 02:55 PM
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.


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

mistwang
04-24-2008, 03:37 PM
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.

tseven
04-24-2008, 05:44 PM
Thank you sh0ck, that was solution, everything works well now.

Cheers :)