Here I know some methods, if you know other please share
- 301 Redirect (PHP Example): A 301 redirect is a permanent redirect from one URL to another. It is used when you want to inform search engines that the original URL has permanently moved to a new location.
<?php
// Permanent 301 redirect
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.newdomain.com/new-page");
exit();
?>
2.302 Redirect (PHP Example):
A 302 redirect is a temporary redirect from one URL to another. It tells search engines that the original URL is temporarily moved to a new location.
<?php
// Temporary 302 redirect
header("HTTP/1.1 302 Found");
header("Location: https://www.newdomain.com/temporary-page");
exit();
?>
3.Canonicalization (HTML Example):
Canonicalization helps address duplicate content issues by specifying the preferred URL version of a page. Use the following link tag within the
4.Meta Refresh (HTML Example):
While not the best option for SEO, you can use the meta refresh tag to redirect users after a specific time delay. Add the following meta tag within the
- JavaScript Redirect (JavaScript Example): Using JavaScript for redirects can be done like this:
<br> window.location.replace("<a href="https://www.example.com/new-page%22">https://www.example.com/new-page"</a>);<br>
6.htaccess Redirect (Apache Server Example):
To implement redirects using the .htaccess file, you can use the following code for 301 and 302 redirects:
301 Redirect
Redirect 301 /old-page https://www.example.com/new-page
302 Redirect
Redirect 302 /old-page https://www.example.com/temporary-page
Top comments (0)