Is it possible to set up a basic HTML page to redirect to another page on load?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
As soon as the page loads, the
init
function is fired and the page is redirected:As far as I understand them, all the methods I have seen so far for this question seem to add the old location to the history. To redirect the page, but do not have the old location in the history, I use the
replace
method:You should use JavaScript. Place the following code in your head tags:
It would be better to set up a 301 redirect. See the Google's Webmaster Tools article 301 redirects.
Razor engine for a 5 second delay:
This is a redirect solution with everything I wanted but could not find in a nice clean snippet to cut & paste.
This snippet has a number of advantages:
How to use:
If you migrated an entire site then on the old server stop the original site and create another with this file as the default index.html file in the root folder. Edit the site settings so that any 404 error is redirected to this index.html page. This catches anyone who accesses the old site with a link into a sub-level page etc.
Now go to the opening script tag and edit the oldsite and newSite web addresses, and change the seconds value as needed.
Save and start your website. Job done - time for a coffee.