Dec 04, 2008, 01:08 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1]   Go Down
  Print  
Author Topic: QUESTION: $modx->sendRedirect issue?  (Read 2465 times)
0 Members and 1 Guest are viewing this topic.
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« on: Jan 05, 2006, 08:43 AM »

Do you know any issue with $modx->sendRedirect()?

I tried to configure newspublisher to my client's need, but for some reason I found out that the redirection is working but it will redirect the user to numbered alias, instead of the given alias on newspublisher. I trouble shoot this, and found out that it's not a problem from $modx->makeUrl(), because the result being generated is including the virtual dir and the alias, instead the sendredirect keep redirecting with a numbered alias such as "http://domain.com/1.html", instead of "http://domain.com/virtualdir/alias.html".

Could somebody help me with this? I tried to see the code, but I don't really have a clue of what's going on with it.

Thanks
Logged

OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,055


looking a little more like my avatar again...


WWW
« Reply #1 on: Jan 05, 2006, 09:40 AM »

Can you show me the call to sendRedirect() and makeUrl() in your code?  I'd be glad to help figure out what's happening.
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
The spirit of a warrior is not geared to indulging and complaining, nor is it geared to winning or losing. The spirit of the warrior is geared only to struggle, and every struggle is a warrior's last battle on earth. Thus the outcome matters very little to him. In his last battle on earth a warrior lets his spirit flow free and clear. And as he wages his battle, knowing that his intent is impeccable, a warrior laughs and laughs.
  — don Juan Matus
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #2 on: Jan 05, 2006, 12:25 PM »

Ehmm,

I checked the makeurl, by calling makeurl, and feeding the function with specific page id, and it shows the full alias with its corresponding virtual dir.

So I assume that the sendredirect is not sending the redirection to the alias path, instead it will use number, because that's what happen in my newspubsliher. When I submit a new page, it will redirect the user to pageid.html, instead of virtualdir/pagealias.html.

I don't know how to check the sendredirect output regarding about this, but the makeurl works like a charm, it proofs the improvement of makeurl, compare to the 0.9.0 version.

Thanks
Logged

OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,055


looking a little more like my avatar again...


WWW
« Reply #3 on: Jan 05, 2006, 01:12 PM »

sendRedirect should be taking you to the URL being returned by makeUrl, if that's how you are calling it.  I cannot reproduce the problem you are describing.  Any kind of code reference here would help me resolve this for you.
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
The spirit of a warrior is not geared to indulging and complaining, nor is it geared to winning or losing. The spirit of the warrior is geared only to struggle, and every struggle is a warrior's last battle on earth. Thus the outcome matters very little to him. In his last battle on earth a warrior lets his spirit flow free and clear. And as he wages his battle, knowing that his intent is impeccable, a warrior laughs and laughs.
  — don Juan Matus
xwisdom
Foundation
*
Posts: 1,732



« Reply #4 on: Jan 08, 2006, 10:26 PM »

Hi,

I've found another issue with sendRedirect(). The problem is that makeUrl returns the url as /[base_url]/[alias].html

From what I understand the Location header requires the full url in order to work properly. This means that it requires the htttp:// portion as well

example:

Code:
// this will fail and cause a 404 error
header('Location: /[base_url]/[alias].html ');

// this will work
header('Location: http://domain.com/[base_url]/[alias].html ');

Tested on IIS 5, Windows XP using WebLogin Snippet

Here's the a quick fix:

Replace line 107 inside the sendRedirect function with:

Code:
// check if url has /$base_url
global $base_url,$site_url;
if (substr($url,0,strlen($base_url))==$base_url) {
// append $site_url to make it work with Location:
$url = $site_url.substr($url,strlen($base_url));
}
$header = 'Location: '.$url;

Please test to confirm.


Logged

xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.
rthrash
Foundation
*
Posts: 9,577



WWW
« Reply #5 on: Mar 11, 2006, 12:50 PM »

Raymond's fix above has been committed as rev 723.
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
luke.stokes
Support Subscriber
*
Posts: 54



« Reply #6 on: Mar 11, 2006, 01:31 PM »

Wendy, how will this effect your subsites?

If there's a mod we need to make, please let me know as I think this might explain the strange errors we have been getting with FirstChildRedirect (hopefully).

Thanks!
Logged
Djamoer
Testers
*
Posts: 1,492

No one can limit a man other than the man himself.


WWW
« Reply #7 on: Mar 11, 2006, 07:24 PM »

I think this will affect the subsites hack.
I hacked the makeurl api to return the cut down version of base url. If you're using the right domain, the cut down base url will work just fine, because I also hacked the main parser to append the missing alias in front of the cut down version of base url.

Now, if this the sendRedirect using the default MODx installation, basically the hack will assume that every base path has to be returned in the right format, so the cut down version will not work.
I'll see whther this is true or not.

Btw, Banzai also having a problem on his site, which I can't figure out why, can you help me determine what's the problem with it? I assume if it works on yours and mine, so it's suppose to work on his.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!