How to Redirect a URL
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 6: Prepare the New Domain and Files
- 1Make sure the new domain is directed to your hosted account.
- 2Download the files from the old domain to your local computer. Keep the same directory structure and file names.
- 3Upload the files from the old domain to the new domain.
- 4Click the start button and choose “Accessories” and “Notepad” to open a text editor.
Method 2 of 6: Use a META Command to Redirect the URL
- 1Open the “index.html” or the file that you want to redirect.
- 2Position the cursor after the HEAD tag in the code.
- 3Type 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.
- 4Add 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.
- 5Save the file.
Method 3 of 6: Use an htaccess File
- 1Find 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.
- 2Understand 300 http codes. The code "301" is most commonly used on redirected sites, and means "moved permanently".
- 3Type 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.
- 4Learn how to redirect a url with spaces in the name, dynamic pages, sub-domains and other special features by searching online.
- 5Change “newdomain.com” to the actual domain name.
- 6Click “save.” Change the dropdown list to “all files.” Save the file as .htaccess with no extension.
Method 4 of 6: Upload and Test the File
- 1Rename 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.
- 2Upload the modified file to the root directory of the old domain.
- 3Type the old domain name in your web browser. It should redirect to the new site.
Method 5 of 6: Use a Service
- 1Various URL redirection services are available to handle the technical bits for you. Depending on your needs, these services may be free or have a small fee associated with their use.
- Usually you just need to edit a DNS record for a domain name you own.
Method 6 of 6: Use Other Code
- 1Find 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.
No comments:
Post a Comment