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
    Feb 2007
    Location
    Norway
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Redirecting and deleting old pages

    I'm in the process of redesigning the structure of my web pages. Now most of the different pages are hard coded and have URLs like http://domain.com/articles/interestingarticle.php, http://domain.com/articles/evenmorei...ingarticle.php and so on.

    With my new and improved system I use a database and the URLs appears like this: http://domain.com/articles/show?id=1

    This means that all my pages will have new URLs, and I need to redirect the old pages to the new URLs. I realize that I can use a Java Script such as:

    Code:
    <meta http-equiv="Refresh" content="0; url="myurl.php">
    <script>
    window.location="myurl.php";
    </script>
    but that means I have to keep all the old pages on the server.

    Anyway, my question is: is there a way I can set up a redirect more simple, and that allows me to remove the old pages from the server?

    Thanks

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,531
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    Maybe using .htaccess? I'm not an expert with htaccess, but look into that.

    See the part here on redirect:
    http://www.thejackol.com/htaccess-cheatsheet/

    More info ... tutorial ...
    http://www.javascriptkit.com/howto/htaccess.shtml

  • #3
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Use htaccess to set your own 404 page (a PHP one). Then in the 404 page attempt to find the page that the user intended to find. If you do find it, use header() to forward the user to the new page (using HTTP code 301 or 302). Otherwise display an informational page stating that the resource is no longer available.


  •  

    Posting Permissions

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