The simplest way to redirect to another URL is to use an HTML <meta> tag with the http-equiv parameter set to “refresh”. The content attribute sets the delay before the browser redirects the user to the new web page. To redirect immediately, set this parameter to “0” seconds for the content attribute.
To redirect from an HTML page, use the META Tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value in the content is the number of seconds; you want the page to redirect after. Set the content attribute to 0, if you want it to load immediately.
To add a new redirect, right click either anywhere on a page and click 'Add current url to Redirector' or right click on a link and click 'Add link url to Redirector'. You can also add urls from Tools->Redirector->Add... but then you won't get the example url filled in.
Go to 'Settings' in the WordPress admin menu and then click on 'Website Redirect'. Enter the URL you want to redirect the site to, set the desired redirection type, set the status to 'Enabled' and save your changes!
document.location.href="/";
document.location.href="/";
or
window.location.href = "/";
According to the W3C, they are the same. In reality, for cross browser safety, you should use window.location
rather than document.location
.
See: http://www.w3.org/TR/Window/#window-location
(Note: I copied the difference explanation above, from this question.)
Can you do this on the server, using Apache's mod_rewrite for example? If not, you can use the window.location.replace
method to erase the current URL from the back/forward history (to not break the back button) and go to the root of the web site:
window.location.replace('/');
window.location.href = "/";
This worked for me. If you have multiple folders/directories, you can use this:
window.location.href = "/folder_name/";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With