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 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Redirect to relative URI

    I want to set up dummy index files in web directories that aren't for general viewing, such as my image and script folders, that will send users to mydomain.com if they type something like mydomain.com/images in the address bar. I am thinking I will use either:
    <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.mydomain.com">
    or
    <?php header( 'Location: http://www.mydomain.com' ); ?>
    However, I'm going to be developing the site on a local server first (I don't even have a web host yet), so I want to use a relative URI that just sends users to the top directory if they try to access any of the places I don't want them to go, so that I won't have to go through and change all these files once I'm ready to get it hosted.

    I seem to remember learning something about this type of redirecting at some point, but can't seem to find anything now. :P

    Thanks in advance for any help.

  • #2
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Can’t you just send them back to their previous page using HTTP_REFERER?

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts
    I don't think so. I hadn't heard of http_referrer before, but it sounds like it would only work if someone has arrived at the directory from a link. I don't intend for any links to exist that might send a person to these areas of my site, I am more interested in stopping people from looking up what is in my directories by typing the url into their address bar directly. Therefore, when they type in a directory I want to keep hidden, they will get the dummy index file which will take them to the main page of my site.

  • #4
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    why not simply
    PHP Code:
    <?php header("Location: /"); ?>

    -Adam
    Why not thank me?

    http://adamsworld.name

  • #5
    New Coder
    Join Date
    Mar 2008
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thanks Adam...do you know a good reference for these types of php commands?

  • #6
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    well php.net is the best. It includes all the commands, gives exmaples, describes how they work, suggests other commands that may work better, and is fairly easy to understand(most of the time).

    If you know the command you are looking for then you can use http://php.net/header or you can go to http://php.net and search for it in the search box in the upper right.


    -Adam
    Why not thank me?

    http://adamsworld.name

  • Users who have thanked GO ILLINI for this post:

    bcatt (05-31-2008)

  • #7
    New Coder
    Join Date
    Mar 2008
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Adam, thanks again.


  •  

    Posting Permissions

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