Move WordPress .htaccess Rules to the httpd.conf File

Move WordPress .htaccess Rules to the httpd.conf File

WordPress SEO friendly permalinks are set via rewrite rules within the root .htaccess file.

Standard .htaccess file WordPress SEO friendly permalink rules.

# 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 above sort of .htaccess file rules in theory can be moved (you don’t HAVE to) to the httpd.conf or domain specific conf file via a Directory directive like this added to the domains VirtualHost directive:

<Directory /home/domainname/public_html>
# 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
</Directory>

After moving the rules your conf file will look something like the screenshot above.

Note: It’s important to wrap the WordPress rules inside a Directory directive, without it, it won’t work.

I added the rules to a conf files which holds the directives/rules for this domain rather than the main httpd.conf file, end result is the same.

Continue Reading Performance Tip: Move Rewrite Rules from .htaccess to httpd.conf