PHP 301 redirect is not redirecting

Discussion in 'PHP' started by Darden12, Jun 1, 2009.

  1. #1
    I'm trying to redirect certain pages using PHP, and all the online instructions tell me to do it as follows. However, when I save a page with this code and try to load it, the PHP does not parse but merely prints out and so there is no page redirection. What am I doing wrong? The page with the script below is in a directory on my site that parses PHP correctly for all my other php pages.

    Thanks,
    Brian



    	 	<?php
    	 	header( "HTTP/1.1 301 Moved Permanently" );
    	 	Header( "Location: http://www.mydomain.com/index.html" ); 
    	 	header( "Status: 301 Moved Permanently" );
     	 	?>
    PHP:
     
    Darden12, Jun 1, 2009 IP
  2. Fr0Gs

    Fr0Gs Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    header ('HTTP/1.1 301 Moved Permanently');
    header ('Location: '.$location);

    Works for me
     
    Fr0Gs, Jun 1, 2009 IP
  3. Darden12

    Darden12 Well-Known Member

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Thanks Frogs,

    For some reason, your code works for me although my original (which I thought said the same thing) didn't.

    Brian
     
    Darden12, Jun 1, 2009 IP
  4. Ralle

    Ralle Active Member

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #4
    I have always used
    header('Location url',true,301);
    PHP:
     
    Ralle, Jun 1, 2009 IP