After migrating web hosts, I encountered a most annoying problem: WordPress permalinks were not working for one of my sites. The main WordPress page loaded just fine, but every attempt at navigating to a post resulted in a dreaded 404 File Not Found error. When hosted on an Apache web server, WordPress uses a .htaccess file to enable pretty permalinks. The Apache Software Foundation, however, discourages the use of .htaccess files. These files can be used to configure directory-specific options. It is recommended to put directory-specific configuration options in the main apache configuration file instead of the .htaccess file. Doing this actually fixed my problem.
In /etc/apache2/apache2.conf, scroll down until you find a section with <Directory> tags. Each of these sections is used to configure directory-specific options. If you’re using a multi-site setup (multiple websites on a single host), you’ll need to add a new <Directory /path/to/website> section. In this section, just paste in everything from the .htacces file that WordPress needs. Then restart apache and you should be golden.
Example portion of apache2.conf file:
<Directory /var/www/mysite> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> </Directory> |