Topic: QUESTION: $modx->sendRedirect issue?  (Read 3461 times)

Pages: [1]   Go Down

#1: 5-Jan-2006, 08:43 AM

Emeritus
Djamoer
Posts: 1,495

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

WWW
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

#2: 5-Jan-2006, 09:40 AM

Foundation

OpenGeek
MODx Co-Founder
Posts: 6,956

damn accurate caricatures...

WWW
Can you show me the call to sendRedirect() and makeUrl() in your code?  I'd be glad to help figure out what's happening.
Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa

#3: 5-Jan-2006, 12:25 PM

Emeritus
Djamoer
Posts: 1,495

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

WWW
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

#4: 5-Jan-2006, 01:12 PM

Foundation

OpenGeek
MODx Co-Founder
Posts: 6,956

damn accurate caricatures...

WWW
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.
Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa

#5: 8-Jan-2006, 10:26 PM

Emeritus
xwisdom
Posts: 1,732

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.


xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.

#6: 11-Mar-2006, 12:50 PM

Foundation

rthrash
Posts: 11,348

WWW
Raymond's fix above has been committed as rev 723.
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#7: 11-Mar-2006, 01:31 PM

Support Subscriber

luke.stokes
Posts: 54

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!

#8: 11-Mar-2006, 07:24 PM

Emeritus
Djamoer
Posts: 1,495

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

WWW
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.
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.