Skip to main content

How to configure the .htaccess file for WordPress

Updated this week

The proper configuration of the .htaccess file is essential to the correct functioning of a WordPress site.

The .htaccess file acts as a control center for Apache. It allows, in particular, to:

  • Manage permalinks (custom URLs)

  • Configure redirects

  • Strengthen security

  • Improve performance

  • Enforce HTTPS

A misconfiguration can cause:

  • 404 Not Found error

  • 500 Internal Server Error

  • Redirect loops

  • Site access issues

Prerequisites

  • Access to the Funio Hub

  • Access to cPanel

  • Access to the File Manager or FTP

Task completion: depends on expertise

Expertise: intermediate

How to do it?

  1. Log in to your cPanel

  2. In the Files section, click on File Manager

  3. Navigate to the public_html folder (or the folder containing your site)

  4. Locate the .htaccess file

  5. Right-click and select Edit

  6. Click Save Changes

  7. Standard configuration for WordPress

The following code is the officially recommended configuration to enable custom permalinks:

# 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

Important :

  • Do not modify the content between BEGIN WordPress and END WordPress, WordPress may automatically rewrite this section.

  • The mod_rewrite module must be enabled.

Enforce HTTPS

To automatically redirect all traffic to the secure (SSL) version:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Protect the wp-config.php file

This file contains the database connection information.

<files wp-config.php>
order allow,deny
deny from all
</files>

Troubleshooting and common issues

Error 500 (Internal Server Error)

Common cause:

  • Syntax error in .htaccess

  • Unauthorized Apache directive

  • Incorrect permissions

Solutions:

  • Rename the .htaccess file to .htaccess_old

  • Test site access

  • Recreate a new clean file

⚠️ Note: A single syntax error in the .htaccess file can make your site completely inaccessible.

Did this answer your question?