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 14 of 14

Thread: URL Replace

  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question URL Replace

    Hi Everyone!

    Need a bit of help here. I own the domain name www.livescripts.co.uk and have just purchased www.livescripts.net. However I want to keep the old domain. All the files will go on www.livescripts.net, and I want a script that will redirect an URL request on www.livescripts.co.uk to the euivalent URL on www.livescripts.net.

    For example, if a user were to request www.livescripts.co.uk/somedir it would be automatically redirected to www.livescripts.net/somedir. I have a feeling that it can be done through HTTP error messages. I have custom pages assigned for each error code. If a 404 is enoucntered, the error appears, but the requested URL remains in the address bar.

    If all errors were redirected to a PHP script that would check the requested URL, and forward to www.livescripts.net + requested URL.

    Any help would be greatly appreciated.

    Jonathan
    ====================
    Jon
    ====================

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    redirect.php

    <?php
    header("location: http://www.livescripts.net".$_SERVER['REQUEST_URI']);
    ?>

    .htaccess

    ErrorDocument 404 /redirect.php

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Sidney!

    Sorry, can't do that, I'm on a Windows server with IIS 6.0

    Any suggestions?

    Jonathan
    ====================
    Jon
    ====================

  • #4
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes go in to internet servise manager and add redirect.php to custom error page for 404 error

  • #5
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Sidney!

    It doesn't seem to work. I just get a normal IE 404 error.

    Jonathan
    ====================
    Jon
    ====================

  • #6
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    did you make it the default

  • #7
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi!

    What exactly do you mean? I made it the default error page, yes. When a 404 error occurs it goes to redirect.php.

    Still does not work though

    Jonathan
    ====================
    Jon
    ====================

  • #8
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    edit/ sorry didnt quite understand last question till i read it again
    wher is redirect.php on server


    in inet servises in left panel highlight the folder containing site

    right click select properties then custom errors

    scroll down list find 404 highlight and edit properties

    select file browse to new file hit ok

    if windows asks to set child properties select all and hit ok

    that should do it
    Last edited by sidney; 04-18-2004 at 12:36 PM.

  • #9
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi!

    Nope, still 404. The file is at http://www.livescripts.co.uk/redir.php. I have made sure that if a 404 error is encountered it will go to that file.



    Jonathan

    PS. I'm testing it using www.hotscripts.com instead of www.livescripts.net, as livescripts.net is not yet fully running.
    ====================
    Jon
    ====================

  • #10
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry requst_uri is apache on windows its like below you can see what you server is using by using phpinfo();
    <?php
    header("location: http://www.livescripts.net".$_SERVER['PATH_INFO']
    );
    ?>
    Last edited by sidney; 04-18-2004 at 01:30 PM.

  • #11
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi!

    Thanks, but it still doesnt work I know hotscripts have a /PHP directory. So it I set the script to
    Code:
    <?php
    header("location: http://www.hotscripts.com".$SERVER['PATH_INFO']
    );
    ?>
    and typed in www.livescripts.co.uk/PHP it should redirect to www.hotscripts.com/PHP right?

    But it doesn't

    Jonathan
    ====================
    Jon
    ====================

  • #12
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    slight mistake $SERVER sholud be $_SERVER corrected below

    header("location: http://www.hotscripts.com".$_SERVER['PATH_INFO']);

    so your being redirect to redir.php by error 404 but its not redirecting on to
    other server may be the php isnt being phrased.
    Last edited by sidney; 04-18-2004 at 03:07 PM.

  • #13
    New Coder
    Join Date
    Mar 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sidney
    may be the php isnt being phrased.
    Sorry Sidney, what does that mean? I'm not very good with PHP.

    Jonathan
    ====================
    Jon
    ====================

  • #14
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    should be parsed ie the page is passed through the php parser and the output is then sent to the browser.

    any way ive been round a m8ts house and on his widows iis 5 tryed it out
    i couldnt get it to hold the path_info when the server redirect on error the path_info was changed to the error page.

    this dosent happen with .htaccess if you use the relative url rather than
    the full url

    so it works perfectly in apache and .htaccess

    but not being to good on windows i cant see a way to hold the initial path_info


  •  

    Posting Permissions

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