1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

header redirects

Discussion in 'PHP' started by obenix, Nov 3, 2005.

  1. #1
    i've got apache, php and mysql installed locally on a windows xp machine.

    in one of my php pages, i've got the following line of code:
    header("Location: http://localhost/index.html");
    exit();
    Code (markup):
    there is absolutely no output to browser before this code. however, the redirect still doesn't happen. any ideas?
     
    obenix, Nov 3, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Is the URL where the script is running public? If so, what's the URL?
     
    digitalpoint, Nov 3, 2005 IP
    obenix likes this.
  3. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Have you tried changing the URL to something different to see if that works?

    eg
    	header("HTTP/1.1 301 Moved Permanently"); 
    	header("Location: http://www.google.co.uk"); 
    	exit();
    
    PHP:
     
    dave487, Nov 3, 2005 IP
    obenix likes this.
  4. dtang4

    dtang4 Active Member

    Messages:
    303
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Do you have error outputting turned on?

    If not, try this:
    error_reporting(E_ALL)
     
    dtang4, Nov 3, 2005 IP
    obenix likes this.
  5. obenix

    obenix Eats an apple a day......

    Messages:
    2,236
    Likes Received:
    180
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for all the help.
    My bad, I missed out on a "print" command earlier in the script. :eek:
    The redirect is working now.

    ** reminding myself to get a new pair of glasses **
     
    obenix, Nov 3, 2005 IP