How to change Apache settings to get custom WordPress permalinks working

By: Kevin | December 12, 2013

I recently installed WordPress on my site. One of the first things I wanted to do was to change the URL’s from the default mcgilln.com/blog/?cat=1 to a more fun, http://mcgilln.com/blog/2013/12/how-to-get-apache-settings-working-for-wordpress-permalink/, which is better for search engine optimization. When I first went into settings and flipped the switch to use the new permalinks I kept getting a server 404 error! I googled around and found out that you need to have  the following code in the .htaccess file in the root folder of your wordpress install location. Sometimes this is generated automatically and other times you need to manually add it (bug?). Do yourself a favor and just open the .htaccess file and make sure the below code is in 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

This was step one of my problem.

The second problem was an Apache setting itself. After a few hours I finally realized the above code was trying to use an Apache module called mod_rewrite.c.. Then I remembered in my httpd.config Apache file (the main Apache settings file) there are tons of lines that are commented out. I did a quick CTR+F and found that the module was commented out and therefore wasn’t being imported for use by Apache! I un-commented the import and restarted Apache but it STILL wasn’t working.
#**This allows writing to .htaccess files so blog permalinks work**
LoadModule rewrite_module modules/mod_rewrite.so

The third and final step was to change permission to the directory where WordPress is located (can be in httpd.config or in the .htaccess file). Change/add the below code and make sure AllowOverride is set to ALL

<Directory "C:/path/to/wordpress/root/directory">
AllowOverride All **<--This is key**
Order allow,deny
Allow from all
</Directory>

After making these changes my WordPress permalinks started working! Hopefully this can help some one save time in the future.