How To Redirect A Website Using .htaccess File


You can use .htaccess file for rewriting your web address. Or you may use any CMS to do this too. But there is a simple way to do so using the meta tag of your pages.
If you want to use the .htaccess file then please refer my last post with title How To Redirect A Website Using .htaccess File

Behind The Scene

If you are going to change the domain name of your website then you must need to redirect all the users to the new pages. The redirections process can be done by using .NET code behind functionalities or by using PHP. You can do this by using the .htaccess file too. But here I got a very simple way to redirect your old web pages to the newly created ones in the new domain.

Now insert the below code to the header section of your web page.
<meta http-equiv="refresh" content="0;url=" />
The above meta tag will refresh the page with a delay of  0 sec and redirects to page.

If you put "5" in place of  "0"  in the content element then the page will be refreshed and redirected after 5 sec. You can put this code in each and every page of your old site and redirect all pages to the corresponding nes pages in the new domain.

Below is a full example on this.
    <meta http-equiv="refresh" content="2;url=" />
    <title>Page Moved</title>
    This page has moved. Click <a href="">here</a> to go to the new page.
The above command will redirect you to after 2 seconds. Hope this may help you.

Happy Coding...

No comments:

Post a Comment