Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    header('Location: ') question

    So I have a header('Location: ') in my script and it works fine if I enter something like

    PHP Code:
    header('Location: profile.php '
    It will go to www.example.com/profile.php

    But I am trying to make it go to the homepage of the site which is just www.example.com. I don't want it to show index.php or default.php.

    So my question is what do I need to put in header('Location: ') for it to direct back to the homepage www.example.com

    Thanks
    Last edited by penny94; 11-04-2012 at 11:04 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    http://www.example.com would do the trick nicely.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    You can either use the full domain, or "/":
    PHP Code:
    header('Location: http://www.example.com/');
    // or
    header('Location: /'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •