Redirect a Web Page
- 301, "Moved Permanently"
- 302, "Found" or "Moved Temporarily"
- HTML Redirect
301, "Moved Permanently"
The HTTP response status code 301 Moved Permanently is utilized for permanent URL redirection, signifying that existing links or records using the URL that triggered the response should be updated. The 301 response from the Web server must always include an alternative URL to which redirection should take place. Once received, a Web browser will promptly attempt to access the alternative URL. Employing this method ensures that users and search engines are directed to the appropriate page accurately. The 301 status code indicates that a page has undergone a permanent move to a new location.
302, "Found" or "Moved Temporarily"
The HTTP response status code 302 indicates that the resource being requested has redirected to another resource. When a 302 "Found" or "Moved Temporarily" redirect is encountered, the server redirects the user to the new destination while still utilizing the original location for subsequent requests. Unlike a 301 status code, which denotes a permanent move, a 302 status code signifies a temporary redirection, and the original URL may be used again in the future.
HTML Meta Refresh RedirectThis method uses an HTML meta tag to instruct the browser to automatically redirect to another URL after a specified time interval. It is a simple way to perform a redirection, but it has limitations, such as not being search engine friendly and not allowing much control over the redirection process. Here's an example of the HTML meta refresh redirect:
Redirect to current URL with URL parameters
To automatically redirect your web page to another webpage upon page load, you can implement the following code. The program displays a brief message for a duration of 3 seconds before initiating the redirection to the specified new page location.
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
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
When you use 301 redirect, you show to Search Engine that current page is permanently moved to another location.
The rel="canonical" meta tag is used to address the issue of duplicate content on the web. When a website has multiple pages that share similar or identical content, search engines may interpret it as duplicate content, which can lead to potential penalties in search rankings. By adding the rel="canonical" tag to a page's HTML head section, you indicate to search engines that this particular page is a duplicate or alternative version of a specified "master page." This helps search engines understand the preferred or authoritative version of the content, ensuring that the correct page is indexed and displayed in search results, while avoiding any negative impact on the website's SEO.
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".