LiteSpeed Support Forums

LiteSpeed Support Forums (http://www.litespeedtech.com/support/forum/index.php)
-   Ruby/Rails (http://www.litespeedtech.com/support/forum/forumdisplay.php?f=20)
-   -   Rails page caching with multiple domains same vhost (http://www.litespeedtech.com/support/forum/showthread.php?t=2477)

nicksnels 11-13-2008 06:31 AM

Rails page caching with multiple domains same vhost
 
Hi,

I have multiple domains running from the same vhost. I have enable page caching in Rails to speed things up, but Litespeed isn't serving these caches. Below is an example to explain the problem. Suppose I have three domains running from the same vhost: www.a.com, www.b.com and www.c.com . Now when somebody visits www.a.com the directory /vhost/public/www.a.com gets generated. When somebody visits www.c.com the directory /vhost/public/www.c.com and so on. But Litespeed doesn't look in these directories but instead only looks in /vhost/public. How can I change this? Thanks.

Kind regards,

Nick

mistwang 11-13-2008 08:22 AM

You need to customize the rewrite rule under the rails context.

nicksnels 11-13-2008 09:36 AM

Found the rewrite rule under the rails context, I tried the following rule:

RewriteRule ^/public/index.html ^/public/%{HTTP_HOST}/index.html [L,R]

But that didn't do it. Are there standard rules for this, since Litespeed already looks for cached pages when there is only one domain. Thanks.

Kind regards,

Nick

mistwang 11-13-2008 09:40 AM

I think it should be

RewriteRule index.html /%{HTTP_HOST}/index.html [L,R]

context level rewrite rule will remove rewrite base from URL.

nicksnels 11-13-2008 10:19 AM

Ok, I found the correct rewrite rule. But I have encountered two problems:

1. when there is no cached file Litespeed returns file not found. It should however instantiate Rails so that a cached file can be generated
2. http://www.a.com/file/show/1 gets redirected to http://www.a.com/domain_name/file/show/1 . But I don't want my visitors, nor the search engines to see this new redirected url.

How can I solve these two issues? Thanks.

Kind regards,

Nick

mistwang 11-13-2008 11:41 AM

1. test if the file exists or not with rewrite condition
2. remove 'R' flag.

nicksnels 11-13-2008 12:46 PM

Ok I got it. Only problem left is when I request www.domain.com/ . Right before I get to the rewrite rules of the rails context, I get:

[REWRITE] strip base: '/' from URI: '/' in the logs

so now I have to match an empty string. I want to redirect www.domain.com to www.domain.com/www.domain.com/index.html . Is this possible? Thanks.

Kind regards,

Nick

mistwang 11-13-2008 03:44 PM

"^$" is a pattern for empty string, it should work exactly the same as non-empty string when you compose the rewrite rule.


All times are GMT -7. The time now is 01:12 PM.