Jump to content
xisto Community
Sign in to follow this  

Url Redirection = Javascript+html Redirect using scripts

Recommended Posts

In javascript Browser redirection can be done in 3 ways:


1) Alert Redirect:

<html><script>	alert("This page has been moved to a new location... click OK to be redirected.");	location = "http://your-website.com;;</script></html>'>http://your-website.com;;</script></html>



2) Confirm and Redirect:

<html><script>	if(confirm("This page has been moved to a new location... would you like to be redirected"))	{  location = "http://your-website.com;;	}	else	{  history.back();	}</script></html>


3) Stealth Redirect:

<html><script>	location = "http://your-website.com;;</script></html>'>http://your-website.com;;</script></html>

Share this post

Link to post
Share on other sites

Browser redirection can also be accomplished through the use of META tags in HTML or through a specific clause in your .htaccess file.



<META HTTP-EQUIV="refresh" CONTENT="5;URL=www.google.de/?gfe_rd=cr&ei=BwkjVKfAD8uH8QfckIGgCQ&gws_rd=ssl;
will change the page to https://www.google.de/?gfe_rd=cr&ei=BwkjVKfAD8uH8QfckIGgCQ&gws_rd=ssl after 5 seconds. Remember that meta tags go within your <head></head> tags.



Redirect /site.html othersite.com/index.html

Whenever it's possible, it's best to use an alterative to javascript, as not all users will have it enabled.

Edited by WindAndWater (see edit history)

Share this post

Link to post
Share on other sites

For some strange reason I can't seem to get redirect to work on my Xisto hosting; my guess is that we don't have mod_rewrite enabled. However, RedirectMatch (allows redirection with regEx matching for the pages) seems to work.

RedirectMatch permanent fromPage.html http://forums.xisto.com/no_longer_exists/
"permanent" tells the browser that the redirection is permanent, but doesn't really affect much -- you can remove it if you want. The second page shouldn't have to use an absolute path, but for some reason it doesn't work on my Xisto account unless I do. To use it, simply copy the code snippit into a text editor, switch out the dummy names with real ones, and then save it as a plain-text file named ".htaccess". Once you're done, upload the file to whichever directory the file you want to be redirected is from. Alternatively, you can have your .htaccess file a few directories up (say in your root directory) and just specify the file by including the path.

Xisto already has a .htaccess file for your www/public_html directory, so if you want to stick your redirection code there, just append it to the other file.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.