301 Permanent Redirects in IIS 7.0 and Apache

301 Permanent Redirects in IIS 7.0 and Apache
Page content

In the previous article in this series, we looked at meta refreshes and how it is the user’s browser that handles the redirection to another web page, directory, or domain. However, search engines such as Google, Yahoo, and Bing sometimes look at meta refreshes as an attempt by the web site to show one content to the search engines but send the user to other content.

This is a problem because the search engines may interpret meta refreshes as an attempt to rank high on a Search Engine Results Page (SERP) for false content but show the real content to users when a visitor requests to view a web page. This happens because the bots that crawl the web in search of content to index in the search engines cannot determine whether the content the user is referred to is really the content indexed in the search engine. This is also a problem for legitimate uses of a meta refresh when the content of a page is located elsewhere and the web administrator just wants the search engines to index the same content that has been permanently moved.

To avoid this problem, you can do a 301 Redirect that tells the search engine that the content on a web page, in a directory, or from entire domain has permanently moved and there is no plan for the content to move back to its old location. Read on to learn how to correctly do a 301 redirect in Apache Web Server and Microsoft’s Internet Information Services (IIS) 7.

301 Redirects Using Apache’s .htaccess Files

To do a 301 Permanent Redirect in Apache you must have access to the .htaccess file located in the root directory of your web site. Keep in mind that many FTP programs hide such files. You don’t want to write over the web site’s current .htaccess files which may contain important information about your domain, web site, and web pages. In fact, editing of the .htaccess files should really only be attempted by an experienced web administrator. Otherwise follow these steps:

  1. Log into your web site using your preferred program and locate the .htaccess file that is normally located in the root web folder. If no .htaccess file is present, you may need to create one but heed the warning about hidden files and FTP programs.

  2. Open the .htaccess file in your text editor of choice and add any of the following lines to the file depending on whether you want to permanently redirect a web page or if you want to redirect an entire domain:

To Permanently Redirect a webpage using a 301 Redirect in Apache Web Server, add either of the following lines to the .htaccess files:

RedirectPermanent /oldwebpagefile.htm https://www.yourdomain.com/newwebpagefile.htm

or

Redirect 301 /oldwebpagefile.htm https://www.yourdomain.com/newwebpagefile.htm

To Permanently Redirect an entire domain using a 301 Redirect in Apache Web Server, add the following line to the .htaccess files:

RedirectPermanent / https://www.yournewdomain.com/

Notice that it is not necessary to specify the old domain in the previous domain redirect example. Google, Yahoo, and Bing will already know that information because the .htaccess file’s location tells the search engines from where to redirect the web page or domain.

  1. Save the file, upload it to the root directory of your web site, and test that the 301 Permanent Redirect is behaving as you intended.

301 Redirects Using Microsoft Internet Information Services 7.0

Just as with the permanent redirect with Apache above, you can accomplish the same 301 Permanent Redirect if your domain is hosted using IIS 7. To implement a 301 Permanent Redirect using IIS 7.0, follow these steps (of course, you will need administrative access to the server that is running IIS 7 to do this):

  1. Click on START>PROGRAMS>ADMINISTRATIVE TOOLS>INTERNET INFORMATION SERVICES (IIS) MANAGER to open the Internet Services Manager.
  1. On the left side of the window, select the web page, directory, or entire site that will be the source of the 301 Permanent Redirect (the web page, directory, or site you will be redirecting from).

  2. In the Internet Service Manage window, use the FEATURES VIEW to click on the HTTP REDIRECT button.

  3. Check the box next to REDIRECT REQUESTS TO THIS DESTINATION and simply type in the address to where you want the 301 Permanent Redirect to go.

For a Web Page, type in: www.yourdomain.com/newwebpagefile.htm

For an entire directory, type in: www.yourdomain.com/newwebdirectory

For an entire domain, type in: www.yournewdomain.com/

  1. Under the Redirect Options section, consider the following choices if you have kept your directories and web pages the same (i.e. no directory restructuring and no changes to file names):

REDIRECT ALL REQUESTS TO EXACT DESTINATION: Check this option only if you want every file within the directory to be redirected to a single page.

ONLY REDIRECT REQUESTS TO CONTENT IN THIS DIRECTORY: Check this option if you want to permanently redirect the directory you have chosen but don’t want to redirect any sub-directories within it.

  1. Again, as with the Apache 301 Permanent Redirect directions above, test that the 301 Permanent Redirect is behaving as you intended.

Conclusion

301 Permanent Redirects are relatively simple to accomplish if you have administrative access to the server on which Apache or IIS 7.0 is running. 301 Permanent Redirects are much better than Meta Refreshes because they are viewed by the Google, Yahoo, and Bing as “white hat” procedures for moving content from one web site or web site location to another. The procedures discussed in this article will typically not cause your website to rank lower on the Search Engine Results Pages (SERP) due to a suspected devious attempt to rank well in the search engines with one content while showing other content to actual visitors to your web site.

This post is part of the series: Meta Refreshes and 301 Permanent Redirects with Internet Explorer 8, Apache Web Server, and Microsoft Internet Information Service (IIS) 7.0

Learn all about Meta Refreshes and 301 Permanent Redirection of Web content using IE8, Apache, and IIS 7. Also, get tips on how to implement a 301 Permanent Redirect in Apache and IIS.

  1. Learn about Automatic Redirection to New URLs in Internet Explorer 8
  2. How to Implement 301 Redirects in Apache and IIS 7
  3. The Basics of 301 Permanent Redirects with ASP, ASP.NET, PHP, and JSP