2009年12月29日星期二

Re: [fw-mvc] BaseUrl and subdomains

I'd probably go with a custom view helper to keep from polluting the router with a server name that only applies to static resources.

--
Hector


On Tue, Dec 29, 2009 at 10:51 AM, Cristian Bichis <contact@zftutorials.com> wrote:
Hi,

I have one small problem while working on a ZF based website.

The website is supposed to work on www.domain.com and some of the parts are working on subdomains as subdomain1.
domain.com, subdomain2.domain.com, aso.

I want to load the static resources (js, css, images) from the main domain, and not from the subdomains, because are the same, for both domain and subdomains. Purpose is obvious: to have the static resources loading from one single location, so it would cache (so everything load faster, no matter on which subdomain we are).

Now: so the resources are loaded from the www.domain.com i'we set the base Url to:

resources.frontcontroller.baseUrl = "http://www.domain.com/"

And the resources are loaded from one location (sample:
http://www.domain.com/images/img1.png), no matter on what subdomain we are... Great...

But there is one problem: seems all the requests for URL's (pages, not static content) are now dispatched to module=default, controller=index, action=index...

As far as i checked the problem is the baseUrl is used also at dispatch.

I have found some workarounds:
1. Use my own helper to point all static resources to the www.domain.com
2. Into a preDispatch i set the baseUrl to http://
www.domain.com/

Both solutions are fine, but i am wondering if there is one more elegant solution...

--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

没有评论: