WordPress / Web Development Tutorials
(Best WordPress Tutorials)

CSSHTMLJavaScriptjQueryMySQLPHPSilvaTechnologiesWooCommerceWordpress
Silva Web Designs - Blog

How to Create the Default WordPress .htaccess File

The .htaccess is a distributed configuration file and is how Apache handles configuration changes on a per-directory basis.

WordPress uses the .htaccess file to manipulate how Apache serves files from its root directory and subdirectories thereof. Most notably, WordPress modifies this file to be able to handle pretty permalinks.

This page may be used to restore a corrupted .htaccess file or a misbehaving plugin.

This is the Default WordPress .htaccess configuration


    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

This is the WordPress .htaccess configuration for a website that has a sub-directory


    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /foldername/
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /foldername/index.php [L]
    </IfModule>
    # END WordPress

As a personal preference, we prefer to have sub-domains for our client’s websites, in all honestly, it makes it so much easier in terms of setting up and not breaking the structure. Should you want to host your websites on sub-directories though, ensure the path is correct and that you update the .htaccess file to accommodate the correct path.

We hope this has helped, thanks for reading!

 

Nathan da Silva - Profile

Posted by: Nathan da Silva

Nathan is the Founder of Silva Web Designs. He is passionate about web development, website design and basically anything digital-related. His main expertise is with WordPress and various other CMS frameworks. If you need responsive design, SEO, speed optimisation or anything else in the world of digital, you can contact Silva Web Designs here; [email protected]

It’s good to share

Join the discussion

Related Posts

Related - How to Install an SSL Certificate on Apache via SSH

Technologies / 20th July 2021

How to Install an SSL Certificate on Apache via SSH

Read More Related - How to Fix The Error: WordPress Needs Access to Your Web Server

Wordpress / 7th September 2020

How to Fix The Error: WordPress Needs Access to Your Web Server

Read More