• I saw that WP does 302 redirect for canonical URLs. I need it to do 301 redirect. Where in the code can I change this? I saw that wp-app.php file has the following code:

    /**
    	 * Display Redirect (302) content and set status headers.
    	 *
    	 * @since 2.3.0
    	 */
    	function redirect($url) {
    
    		log_app('Status','302: Redirect');
    		$escaped_url = esc_attr($url);
    		$content = <<<EOD
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html>
      <head>
        <title>302 Found</title>
      </head>
    <body>
      <h1>Found</h1>
      <p>The document has moved <a href="$escaped_url">here</a>.</p>
      </body>
    </html>
    
    EOD;
    		header('HTTP/1.1 302 Moved');
    		header('Content-Type: text/html');
    		header('Location: ' . $url);
    		echo $content;
    		exit;
    
    	}

    Is this what I need to change and how to change exactly, since I’m not a developer?

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Kejatz

    (@kejatz)

    I just need a simple advice to tweak the code. This should be very simple for someone who is a coder. C’mon don’t be shy.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘I want to change 302 to 301 canonical redirect?’ is closed to new replies.