I learnt about 301 redirection when I moved my wordpress site from earlier domain to this new domain.
Htaccess redirect is better than the meta refresh or redirect tag because there is no delay as the browser reads the .htaccess file first. Here is how it works.
Go to your site’s root folder, download the .htaccess file to your local computer and edit it with a plain-text editor (ie. Notepad). If you are using FTP Client software and you don’t see any .htaccess file on your server, double check your setting and make sure you have turn on invisible / system files.
To Redirect Certain Page(s):
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html Redirect 301 /oldpage2.html http://www.yoursite.com/folder/
To Redirect Entire Site:
Redirect 301 / http://www.new-site.com/
You can also do this by placing an index.php file in the place where you had your earlier site. But its not the right way to do it and will reduce the response time of your site.
1 2 3 4
<?php header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: http://www.new-site.com" ); ?>
Latest posts by Abhishek Gupta (see all)
- Laravel Custom Exception Handlers - March 28, 2019
- Customizing Laravel validation JSON message format - March 20, 2019
- Time killer and addictive Google Games - March 19, 2019