XF 2.2 RM pages => HTTP/1.1 301 Moved Permanently

Robert9

Well-known member
How can I manipulate the RM to show something like this:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: URL_to_thread");
header("Connection: close");
?>

all resources should point to the thread.
all categories should point to the specified forum.


I can try to use two templates.
Or better use an add-on that extends cat and res, fetch forum and thread, echo $output?
 
Code:
    public function actionView(ParameterBag $params)
    {
        $this->assertNotEmbeddedImageRequest();

        $resource = $this->assertViewableResource($params->resource_id, $this->getResourceViewExtraWith());
        
        
        $publicRouter = \XF::app()->router('public');
        $threadLink = $publicRouter->buildLink('canonical:threads', $resource->Discussion);
        

        
        echo "<?php
header(\"HTTP/1.1 301 Moved Permanently\");
header(\"Location: $threadLink\");
header(\"Connection: close\");
?>";
        exit;
 
But:

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
 
Top Bottom