redirects

Hello,

Why when you setup a permanent redirect in the HSphere control panel due you need to have a page with the old name on your site?

Thank you in advance.
 
No, the control panel works as far as saving redirects. But, if you type the original page that in my case no longer exists, you get page not found instead of being redirected. Your tech support representative said you need to have a blank page for each old page that you want redirected this seems a waste to me. Is there a work around for this?
 
For one of my client's sites, I did a custom 404 that redirects from one site to another--whatever document requested at the old site is loaded instead from the new site.

PHP:
if(isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] != '') {
  header('location:http://www.newsite.com'.$_SERVER['REQUEST_URI']);
} else {
  header('location:http://www.newsite.com/');
}
die();

Actually, I did this for a "utility" domain for him--he has a web tool for his use on the one site, but the URL was close enough to his real domain that folks kept landing on his utility domain and getting 404s. This custom 404 sends them to the correct domain without them hardly knowing that they've been redirected.

Tim
 
Hello,

Would this work if you wanted to go from one non-existent page to a new page on the same domain?

Thank you in advance.
 
Not as written. You would basically need a whole bunch of "if...else" statements: if user tries file1.html, give them file2.html, and so forth. And it would be complicated if you have content in subdirectories.

I'd do something like this:

PHP:
<?php
switch($_SERVER['REQUEST_URI']) {
	case '/file1.html':
		header('location:http://www.yoursite.com/otherfile.html');
	break;
	case '/file2.html':
		header('location:http://www.yoursite.com/differentfile.html');
	break;
	case '/directory1/somefile.html':
		header('location:http://www.yoursite.com/yetanotherfile.html');
	break;
	default:
		header('location:http://www.yoursite.com/');
	break;
}
die();
?>

Repeat the case ... break blocks as needed for each of the files you want to redirect. The default block sends requests for files that aren't on your list to your home page.

Tim
 
TrueBlue, I can't help you code up an ASP version of what I did with PHP. But, you should be able to use what I wrote just fine. Make sure PHP is enabled for your site. Edit the code I wrote to point to all the pages you want (html or asp or whatever) and save the result as a .php file. Set up your custom 404 handler to point to that file and it should work just fine. Site visitors probably won't even know there was a PHP page in there unless the server runs really slow that day.

Tim
 
Back
Top