---
title: "How-to Guide: Redirects and htaccess"
description: By Bret Fencl, Fencl Web Design Every time you turn around another article on the Internet tells yo...
image: https://www.websitemagazine.com/hubfs/Imported_Blog_Media/gradient-regular-logo-mark-Jan-23-2023-12-16-40-6236-AM-Apr-10-2023-01-16-27-5489-PM-2-2.png
---

[Log In](https://www.websitemagazine.com/_hcms/mem/login) [Subscribe](https://websitemagazine.tradepub.com/free/w_webk05/prgm.cgi)

[![Website Magazine Logo](https://www.websitemagazine.com/hs-fs/hubfs/gradient-regular@3x-1.png?width=586&height=145&name=gradient-regular@3x-1.png "Website Magazine Logo")](http://Website%20Services,%20Inc.)

- [About](https://www.websitemagazine.com/about) 
    - [FAQs](https://www.websitemagazine.com/about/faq)
    - [Advertise](https://www.websitemagazine.com/about/advertise)
    - [Editorial Staff](https://www.websitemagazine.com/about/editorial-publishing-staff)
- [Resources](https://websitemagazine.tradepub.com)
- [Newsletter](https://www.websitemagazine.com/newsletter-sign-up)
- More 
    - [Contact Us](https://www.websitemagazine.com/contact)

[Log In](https://www.websitemagazine.com/_hcms/mem/login) [Subscribe](https://websitemagazine.tradepub.com/free/w_webk05/prgm.cgi)

Search

- [Latest](https://www.websitemagazine.com)
- [Design](https://www.websitemagazine.com/web-design)
- [Development](https://www.websitemagazine.com/web-development)
- [SEO](https://www.websitemagazine.com/seo)
- [Ecommerce](https://www.websitemagazine.com/ecommerce)
- [Content](https://www.websitemagazine.com/content)
- [Marketing](https://www.websitemagazine.com/marketing)
- [Advertising](https://www.websitemagazine.com/advertising)
- [Email](https://www.websitemagazine.com/email)
- [Infographics](https://www.websitemagazine.com/infographics)
- [View All Topics](https://www.websitemagazine.com/channels)

# How-to Guide: Redirects and htaccess

![Pete Prestipino](https://www.websitemagazine.com/hubfs/Pete%20Prestipino.jpeg)

[by Pete Prestipino](https://www.websitemagazine.com/marketing/author/pete-prestipino) 12 Feb, 2007

- <https://twitter.com/share?url=https://www.websitemagazine.com/marketing/redirects-htaccess-how-to-guide>
- <https://www.facebook.com/sharer.php?u=https://www.websitemagazine.com/marketing/redirects-htaccess-how-to-guide>
- [mailto:?Body=https://www.websitemagazine.com/marketing/redirects-htaccess-how-to-guide](mailto:?Body=https://www.websitemagazine.com/marketing/redirects-htaccess-how-to-guide)
- Link Copied!

![How-to Guide: Redirects and htaccess](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/gradient-regular-logo-mark-Jan-23-2023-12-16-40-6236-AM-Apr-10-2023-01-16-27-5489-PM-2-2.png)

**By Bret Fencl, [Fencl Web Design](https://fenclwebdesign.com)**

---

Every time you turn around another article on the Internet tells you to make a 301 redirect for the obsolete pages on your website. The problem is that most of these articles do not explain how to make a proper redirect.

**First Check for a .htaccess File**  
Check to see if you have a [.htaccess file](https://www.websitemagazine.com/definition/htaccess) in the main directory of your website. The base directory for a website is usually called something like htdocs, httpdocs, www or public, and is the file where your home index page resides.   
   
On many servers the .htaccess file may be hidden from FTP software, so you will want to try accessing it through your Web hosting file manager. If you still cannot find a .htaccess file, then check with your Web hosting company to make sure you do not overwrite it, which could damage your Web hosting or site.  
   
If you find the .htaccess file, make sure you save a backup copy before making any changes to it.

**Creating a .htaccess File**  
If you do not have a .htaccess file you will need to create one.

This is a basic text file and does not have any extension on the end of it. Simply create a new text file and name it .htaccess and save the file starting with a period(.).

Once you upload this file to your server it may become hidden or disappear. But don't worry, it will still function properly.

**Creating a 301 Redirect**  
A 301 redirect is used to send a visitor that was trying to access an outdated page of your website to the new page. This also assists many search engine bots in finding the new page and dropping the old page from the index.

The command you would use in your .htaccess file is simply:  
*redirect 301 oldpage.html newpage.html*

You may also use the same method to redirect visitors from an old file to a new page.  
*redirect 301 /oldfile/ newpage.html*

**Creating a 302 Redirect**  
A 302 redirect is used much the same as a 301 redirect but the difference is that it tells the search engine bots that this move is only temporary and the old page will be returning soon. This is particularly useful for retailers who may have run out of a product and will have it back in stock in a week so you temporarily point the page to a similar product to avoid losing sales.

For a 302 redirect, simply enter this code into your .htaccess file:  
redirect 302 oldpage.html temporarypage.html

**Creating a Mod Rewrite**  
Sometimes you can simply make a redirect by rewriting the name of a new page in the same file directory of a website without actually changing the page name your visitor's access. You need to check with your Web host to see if they allow mod rewrite - many Web hosting companies do.

For example, you have a product that you want to advertise on your website and send to your customers in an email newsletter. A long web address may break when you email a URL such as: https://www.example.com/index.php?cart=98234&id=4593921

Another need for this situation is that it may make it easier to explain the Web address over the phone or write it down for someone on the fly.

The above URL could be shortened to:  
https://www.example.com/widget.php

Here is the .htaccess command for a Mod Rewrite on a URL:   
Options +FollowSymLinks  
RewriteEngine on  
RewriteRule widget.php index.php?cart=98234&id=4593921

Redirects are important for websites to remain up-to-date and for the search spiders to consistently index fresh content. While this is simply a primer to .htaccess and redirects, and you may have to try a little experimenting, soon you will learn fun new uses for redirects and mod rewrite and make sure that your site never appears outdated.

 

**Block Bad Bots**

Some bots will ingnore directions available in the robtoots.txt files but they can be blocked using a .htaccess file. One of the downsides of this method is that you can't actually block bots by their actual name, but you can block them by matching the beginning of the User-Agent string. 

SetEnvIfNoCase User-Agent "^EmailSiphon" bad\_bot  
SetEnvIfNoCase User-Agent "^EmailWolf" bad\_bot  
SetEnvIfNoCase User-Agent "^ExtractorPro" bad\_bot  
SetEnvIfNoCase User-Agent "^CherryPicker" bad\_bot  
SetEnvIfNoCase User-Agent "^NICErsPRO" bad\_bot  
SetEnvIfNoCase User-Agent "^Teleport" bad\_bot  
SetEnvIfNoCase User-Agent "^EmailCollector" bad\_bot

    
Order Allow,Deny    
Allow from all   
Deny from env=bad\_bot

---

   
[![Website Magazine](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/missing-image-Apr-10-2023-01-16-28-1419-PM-2-2.png)](https://www.websitemagazine.com/blogreferrals/?id=50011&f=b_468x60_1_red)

![Pete Prestipino](https://www.websitemagazine.com/hubfs/Pete%20Prestipino.jpeg)

[Pete Prestipino](https://www.websitemagazine.com/marketing/author/pete-prestipino)

Digital marketing executive with proven experience in all aspects of search engine optimization (SEO), performance-based advertising, consumer-generated/social media, email marketing, lead generation, Web design, usability, and analytics. - 20-year Internet marketing veteran, currently serving as the Digital Marketing Campaign Manager at Antenna Group (formerly Chicago Digital). - Former Editor-In-Chief of Website Magazine, and a regular speaker on Web technology digital marketing strategy - Author of several books on digital marketing Including Web 360: The Fundamentals of Web Success; Affiliate 360: The Fundamentals of Performance Marketing; Domains 360: The Fundamentals of Buying & Selling Domain Names, and SEO 360: The Fundamentals of Search Engine Optimization.

- <https://www.linkedin.com/in/prestipino>
- <https://www.antennagroup.com/>
- [mailto:peter@websitemagazine.com](mailto:peter@websitemagazine.com)

#### Popular Post

### [31 Back-to-School Keyword Targets ![31 Back-to-School Keyword Targets](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/schoolbus-1-1-1-1.jpg)](https://www.websitemagazine.com/marketing/31-back-to-school-keyword-targets)

### [GoDaddy Goes .XXX ![GoDaddy Goes .XXX](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/gradient-regular-logo-mark-Jan-23-2023-12-15-39-1451-AM-Apr-10-2023-01-36-09-0977-PM-3-1.png)](https://www.websitemagazine.com/marketing/godaddy-goes-xxx)

### [23 Cool Tech Facts ![23 Cool Tech Facts](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/fact_100x100-2-1-1-1.png)](https://www.websitemagazine.com/marketing/23-cool-tech-facts)

#### Subscribe to Our Newsletter!

[![](https://a.impactradius-go.com/display-ad/13053-1438301)](https://semrush.sjv.io/c/3976891/1438301/13053)![](https://imp.pxf.io/i/3976891/1438301/13053)

#### Latest in Marketing

[![3 Tips to Make Your Website More User-Friendly in 2023](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/pexels-photo-2284350-1-1.jpg) 3 Tips to Make Your Website More User-Friendly in 2023](https://www.websitemagazine.com/marketing/3-tips-to-make-your-website-more-user-friendly) [![Web.com Launches New Professional QuickStart Website Service](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/pexels-photo-4348404-1.jpg) Web.com Launches New Professional QuickStart Website Service](https://www.websitemagazine.com/marketing/web-com-launches-new-professional-quickstart-website-service) [![6 Ways to Stretch Your Marketing Budget](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/gradient-regular-logo-mark-Feb-07-2023-03-32-33-0828-PM-Apr-25-2023-03-10-37-2214-AM-1.png) 6 Ways to Stretch Your Marketing Budget](https://www.websitemagazine.com/marketing/6-ways-to-stretch-your-marketing-budget) [![5 Reasons Visitors Leave Your Website and Website Tracking Tools to Track Website Visitors](https://www.websitemagazine.com/hubfs/pexels-photo-1008155.jpg) 5 Reasons Visitors Leave Your Website and Website Tracking Tools to Track Website Visitors](https://www.websitemagazine.com/marketing/5-reasons-visitors-leave-your-website) [![5 Lessons About Workplace Energy](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/distress-1-1-1-1.png) 5 Lessons About Workplace Energy](https://www.websitemagazine.com/marketing/5-lessons-about-workplace-energy) [![Y Combinator Startups to #WebTechWatch](https://www.websitemagazine.com/hubfs/Imported_Blog_Media/startup-funding-4-1-1-1.jpg) Y Combinator Startups to #WebTechWatch](https://www.websitemagazine.com/marketing/y-combinator-startups-to-webtechwatch)

[![gradient-regular@3x](https://www.websitemagazine.com/hs-fs/hubfs/gradient-regular@3x.png?width=128&height=128&name=gradient-regular@3x.png)](https://www.websitemagazine.com/)

999 E Touhy Ave,

Des Plaines, IL 60018

 

[info@websitemagazine.com](mailto:info@websitemagazine.com)

[(888) 7WEBMAG](tel:18887932624)

[(312) 313-6576](tel:13123136576)

About

- [Advertise](https://www.websitemagazine.com/about/advertise)
- [Editorial](https://www.websitemagazine.com/about/editorial-publishing-staff)
- [Contact Us](https://www.websitemagazine.com/contact)

Resources

Membership

- Login
- Subscribe

Signup for our newsletter

<https://www.linkedin.com/company/website-magazine/> <https://twitter.com/websitemagazine> <https://www.facebook.com/WebsiteMagazine> <https://www.instagram.com/websitemagazine/> <https://www.pinterest.com/websitemagazine/>

 © 2026 Website Magazine. All Rights Reserved

- [Privacy Policy](https://www.websitemagazine.com/about/privacy)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Pete Prestipino",
    "url" : "https://www.websitemagazine.com/marketing/author/pete-prestipino"
  },
  "dateModified" : "2023-05-01T21:25:06.318Z",
  "datePublished" : "2007-02-12T06:00:00.000Z",
  "headline" : "How-to Guide: Redirects and htaccess",
  "image" : [ "https://www.websitemagazine.com/hubfs/Imported_Blog_Media/gradient-regular-logo-mark-Jan-23-2023-12-16-40-6236-AM-Apr-10-2023-01-16-27-5489-PM-2-2.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://www.websitemagazine.com/marketing/redirects-htaccess-how-to-guide",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://www.websitemagazine.com/hubfs/gradient-regular@3x-1.png"
    },
    "name" : "Website Services, Inc."
  }
}
```

```json
{
  "@context" : "https://schema.org",
  "@type" : "NewsArticle",
  "author" : [ {
    "@type" : "Person",
    "name" : "Pete Prestipino"
  } ],
  "headline" : "How-to Guide: Redirects and htaccess",
  "publisher" : {
    "name" : "Website Magazine",
    "url" : "https://www.websitemagazine.com/"
  }
}
```