If you're using Apache and can use a .htaccess
file you should use the following type of redirect. Add the following to an .htaccess
file in the root of your website.
RewriteEngine On
RewriteRule ^/oldfile_path/file_name\.html$ /oldfile_path/file_name.html [R=301,L]
This has the advantage of being a very fast and immediate redirect. It also depends on your reason for the redirect. This is a more permanent method because it sends the HTTP 301 status code signifying that the file has moved permanently and causes many browsers to cache that request. You can change the code to something else like a 302 for temporary redirects.
Otherwise you can do a simple redirect using an HTML <meta>
tag as suggested by others:
<meta http-equiv="refresh" content="5; url=http://example.com/">
By default the content="5"
makes that redirect after 5 seconds. This will be slower and not all browsers support it. A redirect can also be done in the server language of your choice PHP
, Node.js
, etc.