• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Startup Hero

The Official Blog Of Name Hero

Learn To Fly Above The Competition Get Started
  • HomeWelcome
  • CoursesVideo Training Center
  • About UsWhat is StartupHero?
  • BlogGet the latest
  • Start HereStartup 101
  • SpeakingPodcast & Media
  • ResourcesTools to help You
    • Reselling WordPress Hosting
    • Resell Hero
    • How To Start A Blog
  • NameHeroCloud Web Hosting

Why WordPress htaccess Is Important And How To Create It

By Ryan Gray on September 13, 2016 0

Why WordPress htaccess Is Important And How To Create It

One of the most common problems we get in our support desk is with errors in the WordPress htaccess file.

If you’re just installing WordPress for the first time, there isn’t an .htaccess file.  It’s not until you customize your permalinks and save that it automatically generates in the directory you have WordPress installed.

When WordPress cannot gain permissions to automatically generate the file (which can be for a number of reasons) you may find yourself needing to creating your own and uploading it manually.

Manually Create WordPress htaccess

You can easily do this by creating the file inside of cPanel’s file manager:

  1. Login to cPanel
  2. Click File Manager
  3. Navigate to the directory WordPress is installed
  4. Click + File on the top navigation menu (below the cP logo)
  5. Name the new file .htaccess
  6. Click Create New File

Screenshot Of Step 5:

Create WordPress .htaccesd

Once the file is create, you need to add the content.

Enable Hidden Files In File Manager

By default, File Manager, nor most FTP programs show files that start with a period.  To enable this in File Manager, click the settings cog at the top and click the checkmark beside “Show Hidden Files (dotfiles)”:

Show Hidden Files

Click save and you’ll see the new file you created.

Default WordPress htaccess Content

Click on the .htaccess file, then click edit, and fill it with the following default WordPress .htaccess code:

# 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

The finished product should look something like this:

Save .htaccess

Click Save Changes and you will be all set!

Subfolder WordPress htaccess

If WordPress isn’t installed in the root directory you’ll want to use a slightly modified version of the .htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

SubDomain WordPress htaccess

The same goes for those that choose to install WordPress in a subdomain:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

If You Already Have An htaccess File

If you have other software on your website besides WordPress you may already have an .htaccess file.

If so, simply edit your existing file and copy and paste the above codes into it.

Important: It’s always recommended to take a backup before modifying any existing files (trust me I’ve been there not doing it).

Why htaccess Is Important For WordPress

The .htaccess file helps route your URLs.  It’s important to ensure your pages and posts generated by WordPress are named correctly and will be indexed properly by search engines.  Some WordPress plugins can alter this file and cause your entire site not to be viewable.

Making a new htaccess file for WordPress isn’t to complicated but you ALWAYS want to make sure you have a backup if altering your old one.  A good way to do this is to download it to your computer or re-name the existing one .htaccess.bk.

Additional information on your WordPress htaccess file including how to customize it can be found in their support docs.

Feel free to ask any questions below!

Ryan Gray

Ryan Gray is the founder and CEO of NameHero, one of the fastest growing independent web hosts in the United States. Ryan has been working online since 1998 and has over two-decades experience in Internet Entrepreneurship.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Connect With Us!

Superhero Resources

Fix Common Issues

  • How To Setup Free And Automatic SSL Certificates
  • How To Setup Cloudflare With Railgun
  • How To Fix Memory Exhausted Errors In WordPress
  • How To Edit PHP Version/Upload Limit/Add Extensions
  • How To Move/Migrate Your Business To Name Hero

Free Guides

  • How To Setup NameHero Hosting
  • How To Create A Web Hosting Business With WordPress
  • How To Start A WordPress Blog
  • How To Migrate WordPress To A VPS
  • How To Speed Test And Optimize Your WordPress Website
  • Magento 2.X Installation Guide
  • How To Clean Up A WordPress Hack

Training

Recent Posts

  • Using Cloudflare’s “URL Normalization” Rules
  • Will Google FLOC Affect Website Owners?
  • Good Riddance To Contact Forms – Hello Google Forms!
  • How To Identify CLS Issues Using Google Chrome
  • How To Achieve ~90% Cache Hit Ratio On Cloudflare
  • How Does Google Judge EAT? Probably Links!
Subscribe in a reader
  • Web Hosting
  • WordPress Hosting
  • Reseller Hosting
  • VPS Hosting
  • Twitter
  • Facebook
  • LinkedIn
  • YouTube
  • FTC Disclosure
  • Earnings Disclosure
  • Privacy Policy

Copyright © 2021 · Smart Passive Income Pro on Genesis Framework · WordPress · Log in