Can you show me the call to sendRedirect() and makeUrl() in your code? I’d be glad to help figure out what’s happening.
-
- 1,495 Posts
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
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.
-
- 1,732 Posts
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:
// 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:
// 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.
Raymond’s fix above has been committed as rev 723.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
-
- 54 Posts
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!
-
- 1,495 Posts
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.