What I want to do is redirect a URL to it's matching path on another domain.
http://oldexample.com/this-is-the-path/
would redirect to:
http://newexample.com/this-is-the-path/
I've written a PHP script which basically detects and collects the current pages URL, parses it using parse_url, and appends the path onto the new host.
This works on a hosting setup I have elsewhere, however when I try and do it on an IIS server I get a 404 error because it can't find /this-is-the-path/.
What do I need to do to enable this??
Or what would be a smarter way of enabling this kind of redirection?
The code isn't super important because it works on another environment, but will post it anyway:
Brooxy28
1 Post
Setting up comprehensive PHP redirects
Jan 03, 2013 05:24 AM|LINK
Hey guys,
What I want to do is redirect a URL to it's matching path on another domain.
http://oldexample.com/this-is-the-path/
would redirect to:
http://newexample.com/this-is-the-path/
I've written a PHP script which basically detects and collects the current pages URL, parses it using parse_url, and appends the path onto the new host.
This works on a hosting setup I have elsewhere, however when I try and do it on an IIS server I get a 404 error because it can't find /this-is-the-path/.
What do I need to do to enable this??
Or what would be a smarter way of enabling this kind of redirection?
The code isn't super important because it works on another environment, but will post it anyway:
<?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } $url = curPageURL(); header('Location: http://newexample.com' . parse_url($url, PHP_URL_PATH)); ?>HostingASPNe...
734 Posts
Re: Setting up comprehensive PHP redirects
Jan 03, 2013 06:24 AM|LINK
Hello,
You could check at how to make 301 redirect with IIS.
Regards
Free ASP.NET Examples and source code.