LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > Rails page caching with multiple domains same vhost

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2008, 06:31 AM
nicksnels nicksnels is offline
Member
 
Join Date: Feb 2007
Posts: 33
Default 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
Reply With Quote
  #2  
Old 11-13-2008, 08:22 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
You need to customize the rewrite rule under the rails context.
Reply With Quote
  #3  
Old 11-13-2008, 09:36 AM
nicksnels nicksnels is offline
Member
 
Join Date: Feb 2007
Posts: 33
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
Reply With Quote
  #4  
Old 11-13-2008, 09:40 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
I think it should be

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

context level rewrite rule will remove rewrite base from URL.
Reply With Quote
  #5  
Old 11-13-2008, 10:19 AM
nicksnels nicksnels is offline
Member
 
Join Date: Feb 2007
Posts: 33
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
Reply With Quote
  #6  
Old 11-13-2008, 11:41 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
1. test if the file exists or not with rewrite condition
2. remove 'R' flag.
Reply With Quote
  #7  
Old 11-13-2008, 12:46 PM
nicksnels nicksnels is offline
Member
 
Join Date: Feb 2007
Posts: 33
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
Reply With Quote
  #8  
Old 11-13-2008, 03:44 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,603
"^$" is a pattern for empty string, it should work exactly the same as non-empty string when you compose the rewrite rule.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:04 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.