• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Website redirect / .html file location change

Joined
May 18, 2010
Messages
3,427 (0.62/day)
System Name My baby
Processor Athlon II X4 620 @ 3.5GHz, 1.45v, NB @ 2700Mhz, HT @ 2700Mhz - 24hr prime95 stable
Motherboard Asus M4A785TD-V EVO
Cooling Sonic Tower Rev 2 with 120mm Akasa attached, Akasa @ Front, Xilence Red Wing 120mm @ Rear
Memory 8 GB G.Skills 1600Mhz
Video Card(s) ATI ASUS Crossfire 5850
Storage Crucial MX100 SATA 2.5 SSD
Display(s) Lenovo ThinkVision 27" (LEN P27h-10)
Case Antec VSK 2000 Black Tower Case
Audio Device(s) Onkyo TX-SR309 Receiver, 2x Kef Cresta 1, 1x Kef Center 20c
Power Supply OCZ StealthXstream II 600w, 4x12v/18A, 80% efficiency.
Software Windows 10 Professional 64-bit
Lets say the URL is www.test.com/change.html but I later remove the change.html file but I have lots of backlinks pointing to that location still.

Is there a way to redirect users to the home page instead (www.test.com) so the user doesn't get a "page not found" error.

Thanks in advance.
 
If the server supports .htaccess or a server-sided language:
http://en.wikipedia.org/wiki/HTTP_301

If it does not (this will not work if the user has meta refresh disabled so make sure to include an URL to the new page in the body of the page):
http://en.wikipedia.org/wiki/URL_redirection#Refresh_Meta_tag_and_HTTP_refresh_header


If you want to take the first option further, you could redirect all "Not Found" pages to the domain address:
http://www.mcanerin.com/en/articles/301-redirect-404-error.asp

This comment shows how to do this easily in PHP (make the 404 page do a 301 permanent redirect to the top-most folder which should, subsequently, send the user to index.html/index.php):
https://www.drupal.org/node/952162#comment-3621922
 
One option is to create a new change.html like this:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Page Redirection</title>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=http://test.com">
</head>
<body>
<script type="text/javascript">
window.location.href = "http://test.com";
</script>
If you are not redirected automatically, follow the <a href='http://test.com'>link</a>.
</body>
</html>
If meta refresh doesn't kick in, then perhaps the javascript will. Otherwise, the user will have click the link.

Other options include mod_rewrite (Apache) or URL Rewrite (IIS) which could be used to create 301 permanent redirects and more intelligent redirecting. But they may be a little overkill, depending on what you do with your site.
 
Back
Top