Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-02-01 02:03:36

Registered: 2005-09-16
Posts: 10

How to perform 301 redirection from a plugin?


I need to perform 301 HTTP redirection from a plugin (named here my_redirect). The code that performs that looks like

function my_redirect() {
// …
header(‘HTTP/1.1 301 Moved Permanently’);
header(“Location: http://”.$_SERVER[“HTTP_HOST”].”/$path/”);
// …

However, what I receive is the page entitled “200 OK” and text looking like

The document has moved here.
Apache/1.3.41 Server at example.com Port 80

The link “here” directs to the page specified at Location header.

Is it possible to perform an actual 301/302/whatever redirection?


Update: I noticed that the following headers are actually sent:

HTTP/1.1 200 OK
Date: Mon, 01 Feb 2010 02:46:06 GMT
Server: Apache/1.3.41 (Unix) mod_gzip/ mod_log_bytes/1.2 mod_bwlimited/1.4 mod_auth_passthrough/1.8 FrontPage/ mod_ssl/2.8.31 OpenSSL/0.9.8b
Cache-Control: no-cache
Location: http://example.com/somepath/
Connection: close
Content-Type: text/html; charset=iso-8859-1

Is it possible to completely turn off sending headers from other TP code when exit() is called?

The attempt to redirect is made by placing at the very start of a page template the string

<txp:my_redirect deflan=“ru” />

But even if I make the above string the only content of the default page, the mentioned headers are sent anyway.

An advice is strongly required on how to prevent other headers from being sent.

Last edited by boyandin (2010-02-01 02:51:31)

Om gate gate paragate parasamgate bodhi svaha


#2 2010-03-10 15:01:59

Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 351

Re: How to perform 301 redirection from a plugin?

Place your plugin in top your page.
See <txp:aks_301 /> tag in aks_header plugin.

aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)


Board footer

Powered by FluxBB