# Website redirect / .html file location change



## Dent1 (Apr 2, 2015)

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.


----------



## FordGT90Concept (Apr 2, 2015)

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


----------



## Disparia (Apr 2, 2015)

One option is to create a new change.html like this:

```
<!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.


----------

