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.
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.
You mean the address bar does not change?
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?
what about a custom 404 that gives a sitemap?
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();[/PHP]
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(); ?>[/PHP]
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
I forgot to mention I am using ASP.
Any ideas what would work in this case.
Thank you for the help.
I have a bunch of permanent redirects set up in hsphere on a domain that work without the original page existing…
An example redirect in hsphere says:
abc.html-> DOMAIN FOR SALE ( perm )
This has always worked perfectly well (the domain is on win5, btw).
Maybe there is bug is HSphere.
Here is a permanent redirect from my control panel
links.htm-> http://www.sample.com/police-departments.asp ( perm )
Or maybe it is because I am going from HTML to ASP.
[QUOTE=TrueBlue]
Maybe there is bug is HSphere.
[/QUOTE]
what? impossible!
![]()
[QUOTE=TrueBlue]
Here is a permanent redirect from my control panel
links.htm-> http://www.sample.com/police-departments.asp ( perm )
Or maybe it is because I am going from HTML to ASP.
[/QUOTE]
so am I…
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