Default WordPress Htaccess File


If you don’t know exactly what the .htaccess file is, you may have heard it for the first time. A good reason for this is that the .htaccess file is hidden in the root directory of your project by default. Of course, if this is present, it is not always so.

Basic WP

# BEGIN WordPress
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Multi WP

Subfolder Example

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 Example

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]


The .htaccess file is not something unique to WordPress. In fact, you can put any site .htaccess file using Apache Web Server. Htaccess is a configuration file for the server. The web server searches for each .htaccess file when the website is started and runs if the file is located in the project root.

The purpose of the .htaccess file is to reconfigure certain settings of the Apache Web Server. Therefore, it can be said that it will be useful when turning certain features of the server on and off. For example, a typical use case of the .htaccess file is to create redirects from non-www URLs to www URLs and vice versa. Other uses include setting privileges for certain files, blocking bots, or adding MIME types. It is also useful when configuring WordPress security settings. These features are useful during WordPress development because you need to configure some of these settings to best suit your needs.

Leave a Reply

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