Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-02 06:30:48

garrettdimon
Member
Registered: 2005-04-12
Posts: 11

PHP Location Redirect going to a "OK Document has moved Here" page.

I don’t know that it’s a Textpattern issue, but I’ve got a styleswitcher setup at http://www.garrettdimon.com/preferences/.

After clicking the button, it redirects to /setstyles/ which is setup simply as a section in TXP with the page having nothing but PHP to do some cookies and the redirect.

Locally, the redirect works fine, however, on the live site, it goes to an “OK” page which then provides a link to the correct location.

Ideas?

Offline

#2 2005-12-02 07:02:10

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: PHP Location Redirect going to a "OK Document has moved Here" page.

Sometimes this happens if you send a Location: header with a 200 status instead of 301 or 302. On some servers it seems to happen even if you get the status correct, but nobody seems to know why.


Alex

Offline

#3 2005-12-02 07:42:30

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: PHP Location Redirect going to a "OK Document has moved Here" page.

After clicking the button, it redirects to /setstyles/

How are you redireting? Sometimes you have to use Status: 30x and sometimes HTTP/1.1 30x, if it’s from within Textpattern you can use txp_status_header() which makes the decision for you.

Offline

#4 2005-12-02 13:15:12

garrettdimon
Member
Registered: 2005-04-12
Posts: 11

Re: PHP Location Redirect going to a "OK Document has moved Here" page.

Great! Thanks. What’s the difference between 301 and 302? I’ve read about the permanent redirects, but “permanent” makes me feel a little uneasy, since I’m not that familiar with PHP.

Yup, it works. I added “txp_status_header(‘301 Moved Permanently’);” right before the location change and it seems to work great now. I appreciate it.

Last edited by garrettdimon (2005-12-02 13:23:58)

Offline

#5 2005-12-02 14:19:41

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: PHP Location Redirect going to a "OK Document has moved Here" page.

The status codes (302, 301 etc.) are HTTP codes – doesn’t really have anything to do with php.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Though common browser behaviour deviates a little bit from that for the “more esoteric” codes. Browsers will react the same to 301 and 302, but Searchengines may behave differently (In fact there was/is something that got talked about a lot: http://www.google.com/search?q=google+hijacking+302 ). However for you and the style switcher it shouldn’t make much of a difference.

Offline

Board footer

Powered by FluxBB