Tuesday, April 24, 2012

Re: Redirect on new domain with alert

Where is in cakePHP the code that reads the _GET parameters and do the routing to the controller?

@Mark:
I will try the format at http://book.cakephp.org/2.0/en/installation/advanced-installation.html#pretty-urls-on-nginx but the current one wrote in the previews email seems to work fine. Should not it?

@lowpass: The idea is to have 2 site-available in nginx. One has  "server_name www.olddomain.com;" another "server_name www.newdomain.com;". The new one would have a standard nginx configuration for cakephp. The old one wanted to "redirect" every controller/action (not really a redirect but a rewrite of the url in nginx)  to the controller/action OldSite/home with the "real url" the user is trying to access in the newurl param. In this way the only code that has to be aware of the old domain is in OldSiteController.php and in the olddomain.conf file in nginx.

Best,
    Chris
 

On Tue, Apr 24, 2012 at 1:03 PM, lowpass <zijn.digital@gmail.com> wrote:
I don't see why you'd want to pass the entire URL for the old domain.
In any case, leave Cake's 'url' param alone and instead rewrite as
(ONLY if the request is for the old domain):

/index.php?foo=bar&url=$1

Then check to see if the foo param exists. If it does, throw up a
flash message with your notice. Of course, 'foo' & 'bar' can be
whatever you want. Just some simple flag to let your app know that
this request was redirected from the old domain.

And be sure to make it a 301 redirect.

On Tue, Apr 24, 2012 at 2:19 AM, Chris Cinelli
<chris.cinelli@formativelearning.com> wrote:
> I have a a domain: www.olddomain.com
> I am moving to www.newdomain.com
>
> and I am using currently using nginx with this parameters:
>
>     server_name www.olddomain.com;
>     access_log /var/log/nginx.access.log;
>     error_log  /var/log/nginx.error.log debug;
>     root /var/www/webroot/;
>
>     location / {
>         index index.php index.html index.htm;
>         if (-f $request_filename) {
>             break;
>         }
>         rewrite ^(.+)$ /index.php?url=$1 last;
>     }
>     location ~ .*\.php[345]?$ {
>         fastcgi_pass 127.0.0.1:9000;
>         fastcgi_index index.php;
>         fastcgi_param SCRIPT_FILENAME /var/www/webroot$fastcgi_script_name;
>         include        /etc/nginx/fastcgi_params;
>     }
>
> Now I want to redirect the people that are contacting the old domain the the
> exact same place on the new domain BUT I want to communicate the people that
> we have a new domain name.
>
> I thought that the way to do it is to have an address that have a message
> that is a little better but not that different than  "We changed name, you
> will be redirected in 5 sec" and then redirect them to the new domain (that
> nginx should pass as a query parameter called newurl). The redirect splash
> page is at /OldSite/home (but using the old rewrite schema - I am using
> CakePHP)
>
> This is my attempt but it does not work:
>
>     server_name www.olddomain.com;
>     access_log /var/log/nginx.access.log;
>     error_log  /var/log/nginx.error.log debug;
>     root /var/www/html/app/webroot/;
>
>     location / {
>         index index.php index.html index.htm;
>         if (-f $request_filename) {
>             break;
>         }
>         rewrite ^(.+)$
> /index.php?url=/OldSite/home?urlnew=www.newdomain.com/$request_uri last;
>    }
>
> It looks like the rewrite work but it seems that cakePHP does some magic and
> I see the same as I did not change anything: the site completely ignore
> "/OldSite/home?urlnew=www.newdomain.com/". I am not sure what CakePHP is
> doing at the routing level.
>
> Anyway, how can I make it work?
>
> Best,
>    Chris
>
> --Everything should be made as simple as possible, but not simpler (Albert
> Einstein)
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
--Everything should be made as simple as possible, but not simpler (Albert Einstein)

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate