2012-08-06 106 views
1

我希望我的移动Web应用程序使用与我的Web应用程序相同的资源(模型,集合等),但我得到404s。我正在使用RequireJS(加载这些文件),以及Backbone和jQuery Mobile。 m.mysite.com将特定子域名请求重定向到主服务器

/ 
    /js 
    /models 
    /collections 
    /mobile 
    /js 

我的子域/mobile

我的应用程序的结构如下。我希望m.mysite.com/js/models的所有请求都可以重定向到mysite.com/js/models,对于collections和其他类似的请求也是如此。

我想出了下面的代码,但它不工作,我仍然得到404:

# Redirect all calls to '/models' or '/collections' to regular domain 
RewriteRule local\.m\.mysite\.co/js/(models|collections|helpers|objects)/(.*?)$ mysite.co/js/$1/$2 

[L,QSA,R=301] 

注:我前缀我的本地服务器local.

回答

1

你不能在RewriteRule对阵的主机名,你需要使用一个RewriteCond和对阵%{HTTP_HOST}

RewriteCond %{HTTP_HOST} ^local\.m\.mysite\.com$ [NC] 
RewriteRule ^js/(models|collections|helpers|objects)/(.*?)$ http://mysite.co/js/$1/$2 [L,QSA,R=301] 
相关问题