【发布时间】:2013-04-25 14:35:49
【问题描述】:
我在 symfony 1.4 的路由和环境或模块方面有一个严重的问题,所以我创建了三个模块 frontend , mobile 和 backend。
所以在前端和移动模块中,我使用几乎相同的路由:
//apps/frontend/config/routing.yml
home:
url: /home
param: { module: user, action: home }
homepage:
url: /
param: { module: content, action: index }
....
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
移动模块:
//apps/mobile/config/routing.yml
home:
url: /home
param: { module: user, action: home }
homepage:
url: /
param: { module: sfGuardAuth, action: signin }
....
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
我使用该链接访问我的网站
mysite.com/ ==> frontend module(frontend.php)
mysite.com/mobile.php ==> mobile module(mobile.php)
问题是当我正确访问移动版登录页面但登录后他们将我重定向到前端模块的主页而不是移动模块的主页?
备注:
当我将此链接mysite.com/mobile_dev.php 与 dev env 一起使用时,移动版本运行良好!
编辑:
这是我的 htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]
RewriteRule ^(.*) $1? [L]
</IfModule>
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
所以当我将index.php 更改为mobile.php 时,链接mysite.com/mobile.php直接转到移动版主页,一切正常...
所以我现在的问题是如何编辑我的 .htaccess 以像这样重定向我:
mysite.com/index.php or mysite.com/ redirect me to my site
mysite.com/mobile.php redirect me to mobile version
编辑2:
我向你解释一下,当我从这个链接开始时 mysite.com/mobile.php 所以它会将我重定向到移动应用程序以登录页面但是当登录后它转到我的主页新请求搜索默认前端控制器并指向 index.php所以给我前端应用的主页,而不是移动应用!
那么为什么带有mobile_dev.php 的symfony 会一直记住我们在移动开发环境中,而使用mobile.phpit 在第一次重定向时将我从prod mobile env 切换到frontend prod env?
【问题讨论】:
-
您应该检查所有
settings.yml中是否只有一个no_script_name: true。 -
是的,在前端和移动端它们都是 no_script_name:在所有 settings.yml 中都是 true,这意味着?
-
这意味着配置不正确...您应该阅读链接文档。
标签: .htaccess symfony1 symfony-1.4 subdomain