|
|
|
|
ARTICLES ![]() GLOSSARY OF WEB TERMS
![]()
View More >> |
How do I set up a 301 Redirect? 301 redirects often come up in discussions with clients when they are doing some sort of redesign or upgrade where some of their webpages could change or move; or when our monthly Google Webmaster Tools checks report page errors such as 404 page not found errors. A 301 redirect simply tells the search engines that a page has permanently moved from one location to another. The typical scenarios when a 301 redirect is required include:
In addition 301 redirects can be required when:
A 301 permanent redirect is recommended by Google and is seen as best practice around the world. Google provides instruction on 301 redirects in its webmaster support section and even has a video clip to watch: http://www.google.com/support/webmasters/bin/answer.py?answer=93633 301 permanent redirects with Microsoft IIS Web Server In Microsoft IIS all necessary changes can be made directly through the Control Panel. Administrator Mode Administrator Mode is the best method to carry out redirects in a Windows environment for those who can log into the Windows 2000 (or higher) server and access the desktop. This is an example using the IIS 6.0 platform.
301 permanent redirects with Apache Web Server The Linux Operating system most commonly uses Apache web server. Various redirect methods can be used and we have listed a number of common ones below. .htaccess Method This is the best technique for those who have access to the web server and can create and upload an .htaccess file. This option is great as it provides the most control and also flexibility. Apache .htaccess Single Page Redirect Firstly create a file named .htaccess (no extension) then add the code below to the file using a text only editor and upload it to the root directory of your site: RewriteEngine on Redirect 301 /oldpage.html http://www.example.com/newpage.html Apache .htaccess Canonical Redirect As with before you will need to create a file named .htaccess and add the code below to the file using a text only editor and upload it to the root directory of your website. The code provided below will redirect all visitors accessing http://yoursite.com to http://www.yoursite.com: RewriteEngine on rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] Control Panel Method This is a good technique if you have administrator access to the cPanel. Note however that in some cases depending on the setup you might be limited with the types of redirects that you can do and a few control panels do not allow you to setup 301 redirects.
On-page redirects can be a good idea when you only need to 301 redirect a couple of files, or where you don’t have adequate access to the web server (eg if using shared hosting), or if the server is not configured for an .htaccess file. These guidelines apply to both Apache and Microsoft IIS. PHP Single Page Redirect To redirect a static page to a new address just enter the code below into the index.php file. Note that this code needs to be located in a script that is executed on the server before the page content starts: header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.newdomain.com/page.html"); exit(); ?> PHP Canonical Redirect This code redirects all visitors accessing http://yoursite.com to http://www.yoursite.com. It must be located in a script that is executed in every page on the server before the page content starts: if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') { header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.'.$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']); } ?> ASP Single Page Redirect This redirect method is used with the Active Server Pages platform. The code needs to be located in a script that is executed on the server before the page content starts: <% Response.Status="301 Moved Permanently" Response.AddHeader='Location','http://www.new-url.com/' %> ASP Canonical Redirect This code redirects all visitors accessing http://yoursite.com to http://www.yoursite.com. The code has to be located in a script that is executed in every page on the server before the page content starts: <% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME") End if %> Categories: Search Engine Marketing Posted on: 09 May 2011 at 7:25pm by Roy Bowers, modified on: 04 Apr 2012 at 5:06 pm Post CommentCategories |
| |||||||||||
Home . Search Engine Marketing . Search Engine Optimsation (SEO) . Content and Credibility Building . Google Tools and Tracking . Google Adwords . Social Media Marketing . Online Video Marketing . Website Usability . Our Results . Client Feedback . Sample of Clients . Return on Investment . About Us . Our Credibility . Our Team . Our Approach . Community . Contact Us . Glossary of Web Terms . Legal and Terms of Use . Privacy Policy . Site Map . W.O.I. . Website Marketing Review . Blog © Online Advantage 2003 - 2010 CLIENT LOGIN>> | |||||||||||||
| |||||||||||||