Why WordPress htaccess Is Important And How To Create It Print

  • 0

One of the most frequent issues we have on our help desk is with mistakes in the WordPress htaccess file. There is no.htaccess file if you have just installed WordPress for the first time. It does not create automatically in the directory where WordPress is installed unless you have customised and saved your permalinks. When WordPress is unable to get the necessary permissions to produce the file automatically (which may occur for a variety of reasons), you may need to manually create and upload the file.

 

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:

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

 

Enable Hidden Files In File Manager

By default, neither File Manager nor the majority of FTP applications display files that begin with a period. To activate this in File Manager, click the options cog at the top and choose "Show Hidden Files (dotfiles)":

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

 

Default WordPress htaccess Content

Click the.htaccess file, then click Edit, then paste the default WordPress .htaccess code into it:

# 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:

Click the Save Changes button and you're all set.

 

Subfolder WordPress htaccess

If WordPress is not installed in the root directory, you will need to modify the.htaccess file as follows:

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

Likewise, people who opt to install WordPress under a subdomain face the same challenges:

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 use software other than WordPress on your website, you may already have an.htaccess file. If so, just copy and paste the following codes into your current file. Before altering any existing files, it is always advisable to create a backup.

 

Why htaccess Is Important For WordPress

The.htaccess file assists with URL routing. It is essential that your WordPress-generated pages and articles are appropriately labelled and indexed by search engines. Certain WordPress plugins may modify this file, rendering your whole website inaccessible.

Creating a new htaccess file for WordPress is not difficult, but you should ALWAYS create a backup before modifying the existing file. Download it to your PC, or rename the existing.htaccess.abc file to .htaccess.abc. Additional information about your WordPress.htaccess file, including how to modify it, is available in their documentation. Please feel free to ask questions.


Was this answer helpful?

« Back