Changing WordPress permalinks from default to postname
Had an issue on a WordPress site after I changed the permalinks to “%postname%” from the default. Immediately after the change, all my wonderful posts gave 404 when I clicked on them.
So I researched it a bit and found some good recommendations (make sure mod_rewrite is present, check permissions on .htaccess). Initially it looked like a simple fix – the .htaccess file needed to be populated (I didn’t allow the web server daemon write access to that file or the site’s directory). So I added the recommended code to that file directly (by the way, that file needs to be in DocumentRoot for your site). However, that still didn’t fix it.
So I poked around some more and a couple of sites recommended checking AllowOverride and similar settings. In my /etc/httpd/conf/httpd.conf, AllowOverride was set to None.
My sites are in a separate file in /etc/httpd/conf.d so I opened that file and added the following under the VirtualHost section for that site:
<Directory "/site/home">
AllowOverride Options FileInfo
Options FollowSymLinks
RewriteEngine On
</Directory>
(I obfuscated the path above, so in your file, whether /etc/httpd/conf/httpd.conf or a site-specific file in /etc/httpd/conf.d, Directory will certainly not be “/site/home“). You can set AllowOverride to All, but do so at your own risk.
Then I bounced httpd and ta-da, it worked.
So, in summary:
-Check to make sure your web server loads mod_rewrite
-Set .htaccess (found in your site’s root, DocumentRoot) to writable so WordPress can modify it, OR modify it yourself by pasting in the code that WordPress shows you
-In your site’s config (either /etc/httpd/conf/httpd.conf or your site-specific file in /etc/httpd/conf.d), add:
<Directory "/site/home">
AllowOverride Options FileInfo
Options FollowSymLinks
RewriteEngine On
</Directory>
-Bounce the web service