Htaccess file Apache configuration and redirects on Static or WordPress sites

htaccess file

What is the .htaccess File

The .htaccess file is a file that gives commands to apache servers. Windows servers use a similar file called the web.config file but we will only be discussing the .htaccess file in this article.

The .htaccess file is placed in the top level of a websites domain and the server will automatically detect this file and follow the instructions given within. Through inserting certain instructions into this file you can redirect users from one page (or domain) to another, create a personalised 404 error page, password protect folders or allow access to specific users based on their IP address.

Creating your .htaccess file

Creating your .htaccess file is quite simple.

  1. First thing you need to do is to create a new file in notepad
  2. Go to file and then save as.
  3. In the File Name field enter “.htaccess” (including the speech marks as shown in the image)
  4. Press save.

That’s it you have created your .htaccess file and from now on you can just save that file in the normal way. If you didn’t include the speech marks then notepad would just create it as a text file which couldn’t be read by the server.

Htaccess Location

This file then needs to be uploaded to the root directory of your domain using an ftp client such as filezilla or Dreamweaver etc. now all the commands placed in the file will be read by the server.

Read these articles for information on .htaccess commands

Enabling GZIP Compression

Creating Redirects

WordPress Apache htaccess Redirect Configuration: Unleashing the Power of Customization

In this section, we will provide a brief overview of WordPress, Apache, and htaccess, and explain why understanding their configuration is essential for your website’s optimization. 

WordPress: The Leading Content Management System

WordPress is a popular and user-friendly content management system (CMS) that powers millions of websites worldwide. Its flexibility, robustness, and extensive plugin ecosystem make it the go-to choice for businesses and individuals looking to create a dynamic online presence.

Apache: The Reliable Web Server

Apache is the most widely used open-source web server. Its power lies in its ability to handle multiple tasks simultaneously, making it an excellent choice for hosting WordPress sites.

htaccess: Unlocking the Full Potential

The htaccess (hypertext access) file is a configuration file used by Apache to control various aspects of your website. It allows you to set up redirects, rewrite URLs, and enhance your site’s security, among other things. Mastering htaccess will give you complete control over your WordPress site’s functionality.

WordPress Redirects: Enhancing User Experience and SEO

WordPress Redirect Directory: Simplifying Navigation

Redirecting a directory in WordPress can help improve user experience and simplify navigation. By setting up redirects, you can ensure that visitors are directed to the correct page, even if they enter an outdated or incorrect URL.

RewriteEngine On: Redirects using htaccess in WordPress

Your wordpress directory has it’s own .htaccess file. Locate it in the root folder of your wordpress install and follow the following example.

First we turn on the redirect engine which is done with the simple line RewriteEngine On. This command is only input once in the file, no matter how many redirects we want to do. Then on a new line enter

Redirect 301 /old-page.html

<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 /old-page/

The “Redirect 301” is the command and states that this is a permanent redirect. Google will pick up on this also and use it accordingly for SEO purposes. Alternatively you can use a ‘Redirect 302” which states that it is a temporary redirect. In this case Google makes no change to backlink attribution etc.

After entering “Redirect 301” you must leave a space then a forward slash followed by original page you wish to redirect. So in the case of your homepage it would generally be ‘/index.html’. Finally you leave another space and enter the entire path of the new page you want to redirect too.

If you wish to redirect more pages you just simply enter the “Redirect 301 on a new line followed by the links as stated above.

Redirects in WordPress website using plugin

here are several plugins available that specialize in redirect management, making it a breeze to create, edit, and monitor redirects without the need for any complex coding. One popular plugin for this purpose is “Redirection,” which offers a user-friendly interface and a range of useful features. With this plugin, you can easily set up redirects from old URLs to new ones, ensuring that your visitors always find the content they’re looking for. 

Redirection WP Plugin


Redirection is the most popular redirect manager for WordPress. With it you can easily manage 301 redirections, keep track of 404 errors, and generally tidy up any loose ends your site may have. This can help reduce errors and improve your site ranking.

Default WordPress htaccess: Unleashing the Power of Customization

WordPress comes with a default htaccess file that provides a basic level of functionality. However, customizing this file can significantly enhance your site’s performance, security, and SEO.

WordPress Plugins and Themes: Extending Functionality and Flexibility

WordPress Site URL: Optimizing Your Site’s Structure

The WordPress Site URL determines the path to your website, and optimizing it can improve your site’s visibility and SEO. Learn how to configure the Site URL using the htaccess file for maximum control.

Hidden File: Enhancing Security and Privacy

By using htaccess, you can make certain files and directories hidden from public view, adding an extra layer of security to your WordPress site. We will guide you through the steps to safeguard sensitive information and protect your site from unauthorized access.

Server Configuration: Unlocking the Full Potential

Server Configuration File: A Comprehensive Overview

Understanding the server configuration file is crucial for optimizing your WordPress site. We will explore the main server configuration file and show you how to make the necessary adjustments for improved performance and functionality.

Server Side Includes: Creating Dynamic Content

Server Side Includes (SSI) allow you to insert dynamic content into your web pages, such as date and time stamps or file information. Discover how to leverage SSI in your WordPress site using the htaccess file.

Custom Error Pages: Engaging and Informative

Custom Error: Turning Errors into Opportunities

Custom error pages are an excellent way to turn frustrating user experiences into engaging opportunities. Learn how to create custom error pages that provide valuable information and keep visitors engaged with your site.

WordPress Hosting: Optimizing Performance and Security

WordPress Multisite: Managing Multiple Sites with Ease

Using WordPress Multisite, you can manage multiple websites under one WordPress installation. We will guide you through the setup process and explain how to configure your htaccess file for optimal performance.

WordPress Security: Safeguarding Your Site

Ensuring the security of your WordPress site is paramount. We will discuss various security measures you can implement to protect your site from vulnerabilities, including configuring the htaccess file to enhance security.

Bullet Point Summary:

  • Understand the power of WordPress Apache htaccess redirect configuration
  • Unlock the full potential of WordPress plugins and themes
  • Optimize your server configuration for enhanced performance
  • Create engaging custom error pages to keep visitors on your site
  • Take your WordPress hosting to the next level with advanced performance and security measures
    In conclusion, mastering WordPress configuration using the htaccess file is essential for optimizing your site’s performance, functionality, and security. By following the steps outlined in this guide, you will have the skills and knowledge to take your WordPress site to new heights. So, why wait? Start optimizing your WordPress site today!

I am a self-motivated, passionate website designer and developer. I have over ten years of experience in building websites and have developed a broad skill set including web design, frontend and backend development, and SEO.

Using my growing knowledge base I have built my own company ( creating websitese-commerce stores and producing custom graphics and web app functionality for a range of local businesses.

Follow by Email
Scroll to Top