---
title: "Why Prioritize Redirects in .htaccess?"
description: "First, it's important to understand why redirects are present in the .htaccess file. As defined in our article, the .htaccess file is a hidden text file that allows you to control the way visitors..."
url: https://www.inmotionhosting.com/support/website/why-prioritize-redirects-in-htaccess/
date: 2022-02-26
modified: 2022-02-26
author: "InMotion Hosting Contributor"
categories: ["Website"]
type: post
lang: en
---

# Why Prioritize Redirects in .htaccess?

![](https://www.inmotionhosting.com/support/wp-content/uploads/2022/02/why-prioritize-redirects-1024x538.png)

First, it's important to understand why redirects are present in the .htaccess file. As defined in our [article](https://www.inmotionhosting.com/support/website/where-is-my-htaccess-file/), the .htaccess file is a hidden text file that allows you to control the way visitors access your site. For this reason, redirects are placed in the .htaccess file so that when a user types in a specific URL related to your website, then they are immediately sent to the right location.

- [The Problem with some redirects in .htaccess](#the-problem)
- [Solving the problem](#the-solution)

## The Problem with some Redirects in .htaccess

The main issue that happens with redirects is when there are many redirects being defined in the .htaccess file, there can be conflicts. Occasionally, there might be a redirect that is overriding or affecting another redirect.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com

RewriteCond %{HTTP_HOST} ^www.example.com

RewriteRule ^(.*)$ https://example.**net**/$1

The redirect above is a 301 redirect for "example.com" or "www.example.com".

If another redirect was added that was specific to an "example.com" page that you wanted to go to a different URL and NOT be associated with "example.net", then that redirect would need to be defined BEFORE the existing redirect.

If the redirect for the page was placed immediately after the rewrite rule, then the existing re-write rule would have priority and your re-direct would not work.

This is can be very confusing, so let's try making this more visual to clearly define the issue:

## Solving the Problem

![](https://www.inmotionhosting.com/support/wp-content/uploads/2022/02/redirect-position-4.jpg)

The redirect at the bottom *would *work if it were placed at the top of the .htaccess file. This is an example where prioritizing certain redirects would enable them to work properly.

---

So, if you have a number of redirects in your .htaccess file, you need to do a few things:

- Identify each redirect and where they're set to go
- Determine if there are any conflicts with the existing redirects
- Put the redirects in order so that they all can work properly
- If necessary re-write existing redirects or remove them as needed

Redirects can be identified through *rewrite *rules or simple *redirect *rules. Check out our article on [common redirect types](https://www.inmotionhosting.com/support/website/setting-up-a-301-permanent-redirect-via-htaccess/) for more information.
