Wednesday, 4 June 2014

How to Redirect a URL

Posted by Sufyan Hacker  |  at  10:03:00

There are several reasons to redirect a URL. You may have moved content from one domain to another and need to redirect visitors from the old site to the new one. You may have several domains that need to be directed to a single website. Or you may need to direct a website without the "www" to the proper site. A manual error page and redirect from the old site to the new one is the simplest option, but not always the best one. For a website that already has a lot of traffic and good search results, manual redirection means starting from scratch and building traffic all over again. In addition, visitors may become frustrated by having to click on a link. In the methods discussed here, traffic still goes to the old domain, but is redirected to the new one. In time, as search engines update their databases, the new domain will pick up search results. The difficulty in learning how to redirect a URL depends on what code the website is written in and how much experience you have with editing code.

Method 1 of 5: Prepare the New Domain and Files

  1. 1
    Make sure the new domain is directed to your hosted account.
    1. Download the files from the old domain to your local computer. Keep the same directory structure and file names.
    2. 3
      Upload the files from the old domain to the new domain.
    3. 4
      Click the start button and choose “Accessories” and “Notepad” to open a text editor.

    Method 2 of 5: Use a META Command to Redirect the URL

    1. 1
      Open the “index.html” or the file that you want to redirect.
    2. 2
      Position the cursor after the HEAD tag in the code.
    3. 3
      Type in the following:
      • <meta http-equiv="refresh" content="0; URL=http://www.newsite.com/newurl.html">
      • "0" here stands for number of seconds before redirect happens. The www.newsite.com/newurl.html line is the website and the specific webpage that the page is to be redirected to.
    4. 4
      Add text to create a custom error page, if desired. Include an announcement that the site has moved. Add the new site name, with a link that can be clicked manually. Change the refresh time so that it allows the reader enough time to read the message.
    5. 5
      Save the file.

    Method 3 of 5: Use an htaccess File

    1. 1
      Find out if your website is running on an Apache server. The htaccess file on an Apache web server handles error requests, redirection and other requests.
    2. 2
      Understand 300 http codes. The code "301" is most commonly used on redirected sites, and means "moved permanently".
    3. 3
      Type or paste the following code into the text file:
      • RewriteEngine On
        RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
      • “L” indicates that it’s the last instruction and “R” means redirect, and “301” means a permanent redirect.
    4. 4
      Learn how to redirect a url with spaces in the name, dynamic pages, sub-domains and other special features by searching online.[1]
    5. 5
      Change “newdomain.com” to the actual domain name.
    6. 6
      Click “save.” Change the dropdown list to “all files.” Save the file as .htaccess with no extension.

    1. 1
      Rename any existing .htaccess files or html files with the same name to keep a backup copy. Use .htaccessbackup or something similar so that you can find and recognize the file if you need to do a restore.
    2. 2
      Upload the modified file to the root directory of the old domain.
    3. 3
      Type the old domain name in your web browser. It should redirect to the new site.

    Method 5 of 5: Use Other Code

    1. 1
      Find out what code your site is written in. There are different commands for each type of code.
      • You can find code for PHP, ASP, Coldfusion and Javascript redirects online.[2]

Tagged as:
About the Author

I'm a Sufyan Minhas 16 Years Old Young Boy From Lahore Pakistan. I'm a WebMaster of the Pkhackingtricks.blogspot.com. Blogger and SEO Expert. Love to serve myself by sharing Tutorials, Tips Tricks about Internet, Computer Search Engine Optimization, Blogging Ideas. Facebook Account: https://www.facebook.com/HaCkeRnCraCkeR ..

0 comments:

Subscribe
Get our latest posts directly in your email inbox.Click on RSS

Google+ Badge

Followers

Copyright © 2016 Hacking Tips and Tricks Designed By Sufyan Hacker
back to top
' type='text/javascript'/>