I have a serious problem about routing and envirenement or module in symfony 1.4,so I created three modules frontend , mobile and backend.
So in frontend and mobile module,I'm using almost the same routing :
//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/*
mobile module :
//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/*
I use the link to access to my site
mysite.com/ ==> frontend module(frontend.php)
mysite.com/mobile.php ==> mobile module(mobile.php)
The problem is when I access to mobile version to login page correctly but after login they redirect me to homepage of frontend module not to the home page of mobile module?
Remark :
when I use this link mysite.com/mobile_dev.php
with dev env the mobile version works very fine!
Edit :
here is my 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>
So when I change index.php
to mobile.php
the link mysite.com/mobile.php
go directly to to mobile version homepage and all works fine...
So my issue now is how to edit my .htaccess to redirect me like this :
mysite.com/index.php or mysite.com/ redirect me to my site
mysite.com/mobile.php redirect me to mobile version
Edit2 :
I explain you,when I start with this link mysite.com/mobile.php
so it redirect me to mobile apps to login page but when after login instead it go to my homepage the new request search default front controller and it point on index.php so that give me the homepage of frontend apps not the mobile apps!
So why symfony with mobile_dev.php
keep in memory it all time that we are in mobile dev env and with mobile.php
it switch me from prod mobile env to frontend prod env in first redirection?
The sfGaurdModule redirects to route homepage
after successful login. Your homepage
route in both apps have a URL defined as /
. So when you login to frontend
or mobile
you are redirected to http://mysite.com/
.
As one URL can only describe one resource there is no way your web server can understand which application you want to use when it gets the URL http://mysite.com/
. It looks into .htaccess and sees that it should treat this URL as referring to http://mysite.com/index.php
(frontend application). That's why you get redirected to frontend all the time.
There is nothing you can do with .htaccess to change it as you will never be able to differentiate just the URL http://mysite.com/
.
What you can do is:
either change the URL of the homepage for mobile app to e.g. /mobile_home
and switch no_script_name
to false
for the mobile app
or overwrite the signin()
function of the sfGuardAuth
module so it will redirect to different pages based on the application you now use.
Either way remember to set no_script_name
to false
in one of your apps as it will always cause a problem if you don't do this.
As for the dev
environment. It works because after login in dev you are never redirected to /
but either to frontend_dev.php
or mobile_dev.php
so the server does not get confused.