However there are many ways to redirect website's but here are simple ways by examples, This question often comes in-front of you when giving interview for web designer or developer.
For this example I will use the website: http://www.domain.com
Let’s say this site is build in the folder: /folder/ we need a redirect from
DOMAIN to DOMAIN/FOLDER.
META Tags:
Create in the root of your domain an index.html and use a meta-refresh tag in the of your HTML.
This way of redirecting is according to W3C not so nice, and it also will have a delay.
You can set this delay, however I set it to 0.
<meta http-equiv="refresh" content="0;URL=http://www.domain.com/folder/" />
Link :
Not so nice, but to most accessible way, is to just create an empty index.html with an hyperlink
to your new folder.
<a href="http://www.domain.com/folder">Your link</a>.
Javascript :
A good way to use. However if Javascript is disabled in your browser your stuck on the page where this
Javascript code is placed. (index.html in the root of your domain)
<script type="text/javascript">
window.location="http://www.webgeek-tutorials.blogspot.com/folder/";
</script>
Server side :
This will work on Apache linux servers only.
Create with notepad a file called: .htaccess with the below content. Place this file in root of your domain.
Please note that on some servers you can not see this file with your FTP client. I found out that most of the time the webvariant of your hosted server (file manager), will show them.
However, I think this is the best and fastest way of redirecting.
RewriteEngine on
rewriterule ^(.*)$ http://www.domain.com/folder/$1 [r=301,nc]
Welcome to the GEEK world, best place where you find topic about latest cutting edge technology on website and mobile. Learn and grow your knowledge with the information and tutorials about Website designing, CSS tutorials, Java Script tutorials, Ruby tutorials, ROR tutorials, HTML tutorials, HTML5 , JQuery, Javascript tutorials, Photoshop tutorials, Flash, games tutorials, Cheat sheets, Design tools, Action Scripts as well as MySql, Oracle and many more in a easy way to use and understand.
Tuesday, July 12, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment