how to manange redirect 301 locally

Discussion in 'Apache' started by jasongr, Mar 22, 2006.

  1. #1
    Hello people

    I am using Apache 2.0.55 Web server as a service on top of Windows machine
    I am using PHP as a server side script

    During debugging my application locally on 'localhost'
    I performed some 301 redirects on some pages.

    Now I cannot make Apache forget about these redirects
    For example
    I used PHP to peform 301 redirect from
    http://localhost/test.php?p=1
    to
    http://localhost/test.php

    I now regret this, but everytime I go to http://localhost/test.php?p=1, I am being taken to
    http://localhost/test.php

    Since this was done locally, I hope there is a way to tell Apache to forget about this changes
    Am I right?

    Any help would be appreciated
    regards
     
    jasongr, Mar 22, 2006 IP
  2. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    What did you do to perform these 301 redirects ? DId you do it within the PHP programs or did you use .htaccess ?

    Jean-Luc
     
    Jean-Luc, Mar 22, 2006 IP
  3. jasongr

    jasongr Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I used the following syntax to perform the 301 redirect:
    
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://localhost/test.php");
    exit;
    
    PHP:
    I got to that page using the URL:
    http://localhost/test.php?p=1
    and that caused it to be redirected to http://localhost/test.php
     
    jasongr, Mar 22, 2006 IP
  4. Canada Web Design

    Canada Web Design Active Member

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    88
    #4
    take out that 301 redirect you dont need it, instead use a modrewrite within you .htacess to accomplish what you need
     
    Canada Web Design, Mar 22, 2006 IP
  5. jasongr

    jasongr Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    There are 2 problems with that solution:
    1) It doesn't solve my problem. I still want to be able to go to http://localhost/test.php?p=1 without losing my parameter
    2) I cannot let Apache do this redirect as it should only happen upon very specific conditions that I can only verify in PHP

    any other suggestions?
     
    jasongr, Mar 22, 2006 IP
  6. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if($p==""){
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://localhost/test.php");
    exit; 
    }
    PHP:
     
    mad4, Mar 22, 2006 IP
  7. jasongr

    jasongr Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Maybe I am not being clear.
    I don't want to know whether I need to redirect or not
    I don't want to know how I can perform redirect in other means, or how can I use logic to decide whether to perform redirect

    I already performed the permanent (301) redirect.
    It is done already - Take it as a fact

    I want to revert what I did and to cause apache to forget that it was ever done
     
    jasongr, Mar 22, 2006 IP
  8. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #8
    This does not make sense to me. Apache will not remember what you put in a PHP program yesterday, if you change it today.

    I am still not understanding what you try to achieve.:confused:

    Jean-Luc
     
    Jean-Luc, Mar 22, 2006 IP
  9. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Just delete the redirect code from the page and it will stop working.

    Maybe you need to refresh the page to get rid of the cached copyas well.
     
    mad4, Mar 22, 2006 IP