URL redirection
Redirect a Web Page
Web Page redirection, also called URL forwarding or URL redirection, is a World Wide Web technique for making a web page available under more than one URL address. For example, a user visits "example.com/page-1" in their browser and they are redirected to "example.com/page-2" instead. The redirected page is often on the same website, or it can be on a different web site or a web server. There are four main kinds of redirects: 301, 302, HTML Redirect and JavaScript Redirect.
1. 301, "Moved Permanently"
2. 302, "Found" or "Moved Temporarily"
3. HTML Redirect
4. JavaScript Redirect
301, "Moved Permanently"
The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records using the URL that the response is received for should be updated. The 301 response from the Web server should always include an alternative URL to which redirection should occur. If it does, a Web browser will immediately retry the alternative URL. This is the best way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.
302, "Found" or "Moved Temporarily"
The 302 status code indicates that the resource you are requesting has redirected to another resource. With a 302 "Found" or "Moved Temporarily" redirect, the server redirects the user to the new destination despite the original location still being used for requests.
HTML Redirect
Meta Refresh redirect is a client side redirect and is not 301 permanent redirect. This is the simplest way to redirect to another URL is with the HTML Meta Refresh tag. We can place this meta tag inside the < head > at the top of any HTML page like this:
The content attribute is the delay before the browser redirects to the new page, so here it set to 0 seconds. It is important that the time-out is set to zero, to avoid that content is displayed before the new page is loaded. The page containing the redirect code should only contain information related to the redirect.
Full Source
Redirecting Pages in HTML 5
The above code will work in the HTML 5 also.
Javascript URL redirection

You can redirect a web page to another page in a number of ways including JavaScript redirects, server-side redirects, HTML meta refresh redirects etc. You can redirect a web page via JavaScript using a number of methods. Almost all Javascript redirect methods are related to window.location object, which is a property of the Window object, because it control over what page is loaded into the browser rests in the JavaScript property window.location property.
The above Javascript code redirect the current page to https://net-informations.com/faq page.
Full SourceRedirect to current URL with URL parameters
The following Javascript code show how to pass parameter while in page redirection
Both are different, window.location is an object containing the property while location.href which is a string. The window.location is an object that holds all information about current document location (host, href, port, protocol etc.). The location.href is shorthand for window.location.href, and this is only string with full url to current website. The location object's toString() value is the same as the href property, so they are identical if used as strings. Setting window.location is the same as setting window.location.href.
The above Javascript code sets the new href (URL) for the current window.
URL Redirection on page loadIf you want to redirect your web page to other webpage while on page load, you can use the following code. The following program shows a message for 3 second and redirected to new page location.
Please wait....this page will redirect to new page....
There are situations that if someone wants to redirect back to home page then he can use the following javascript code.
There are some other ways to page redirection in Javascript
This is the same as clicking the "Back button" in your browser, or history.go(-1).
How to redirect your website to its mobile version

There are situations that you want to redirect your website to its mobile version. For example, if someone visits example.com on their phone, you'll need a way to redirect them to m.example.com (in case, if the mobile version of your site created on a subdomain called "m"). The following Javascript code will help you to redirect to your mobile version.
Note: Normally mobile phones typically have a small screen width, so you should redirect visitors to your mobile site if they have a screen width of less than or equal to 699 pixels.
For iPhones and iPods
The above code only detects iPhone and iPod. The downside of a JavaScript approach is that not all mobile phones support it and people can always turn off JavaScript in their browsers.
Search Engine Optimization and URL redirection
Normally, Search engines use the 301 status code to transfer the page rank from the old URL to the new URL. The Javascript redirection return http response status code: 200 OK. So Javascript redirection is not search engine friendly redirection and it is better to use some other redirection methods that return status code: 301 Moved Permanently. For example, If you want to notify the search engines (SEO) about your URL forwarding, you should add the rel="canonical" meta tag to your website head part because search engines don't analyze javascript to check the redirection.
When you use 301 redirect, you show to Search Engine that current page is permanently moved to another location.
Cannonical is used to prevent penalties by Search Engine for duplicate content. When you use it, the current page exists but shows to Search Engine that is "copy" of another "master page" . From the following example you will get a clear idea about this.
http://example.com/demo-1.html
http://example.com/category-1/demo-1.html
http://example.com/category-1/subcategory-1/demo-1.html
The above 3 url are same and exact content. Normaly Search Engines doesn't like the duplicate content and give penalties too. So in this case you should put in every single page a rel canonical tag to the "master" page. For example we will chose "http://example.com/category-1/subcategory-1/demo-1.html".
NEXT.....How to Download YouTube Videos