...

View Full Version : URL Replace



GeForce
04-17-2004, 06:05 PM
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 :cool:

sidney
04-17-2004, 11:30 PM
redirect.php

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

.htaccess

ErrorDocument 404 /redirect.php

GeForce
04-18-2004, 10:46 AM
Hi Sidney!

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

Any suggestions?

Jonathan :cool:

sidney
04-18-2004, 10:53 AM
yes go in to internet servise manager and add redirect.php to custom error page for 404 error

GeForce
04-18-2004, 11:14 AM
Hi Sidney!

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

Jonathan

sidney
04-18-2004, 11:16 AM
did you make it the default

GeForce
04-18-2004, 11:27 AM
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 :confused:

Jonathan

sidney
04-18-2004, 11:33 AM
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

GeForce
04-18-2004, 11:42 AM
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.

:confused:

Jonathan

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

sidney
04-18-2004, 11:54 AM
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']
);
?>

GeForce
04-18-2004, 11:59 AM
Hi!

Thanks, but it still doesnt work :rolleyes: I know hotscripts have a /PHP directory. So it I set the script to

<?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 :confused:

Jonathan

sidney
04-18-2004, 02:00 PM
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.

GeForce
04-18-2004, 05:06 PM
may be the php isnt being phrased.

Sorry Sidney, what does that mean? I'm not very good with PHP.

Jonathan

sidney
04-18-2004, 05:14 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum