Installing WordPress on a local server environment is fairly straight forward. There are numerous guides to be found on the Internet that’ll walk you through each step.
However, if your local server environment is running on a Mac, the local Apache server may have some difficulty serving WordPress posts and pages resulting in Error 404 Object not found! errors. These errors can often be attributed to the use of custom or so-called pretty permalinks.
The default permalink structure in WordPress is http://domain.com/?p=123. Any other structure requires an .htaccess file containing mod_rewrite directives to re-write the permalink URLs correctly. The kind of directives that are allowed in .htaccess files are controlled by the Apache server’s configuration file: httpd.conf.
The configuration file for the Apache server that ships with Mac OS X is /private/etc/apache2/httpd.conf. The directory where web pages are stored, known as the document root, is set to /Library/WebServer/Documents by default and in the Mac OS X Apache server is configured as follows:
# # This should be changed to whatever you set DocumentRoot to. # <Directory "/Library/WebServer/Documents"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # Options Indexes FollowSymLinks MultiViews # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory>
On line 214 the AllowOverride directive is set to None. This instructs Apache to completely ignore .htaccess files. Consequently any re-write rules required for pretty permalinks will not be executed resulting in Error 404 Object not found! errors.
The fix is simple and there are two choices: set the AllowOverride directive to FileInfo or All.
Setting the AllowOverride directive to FileInfo allows the use of mod_rewrite directives in .htaccess files.
# # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride FileInfo </Directory>
Setting the AllowOverride directive to All allows the use of all permissible .htaccess directives in .htaccess files.
# # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All </Directory>
Finally, restart the Apache server to ensure the change takes effect.
For local server environments provided by XAMPP the document root configuration can be found in /Applications/XAMPP/xamppfiles/etc/httpd.conf.
For MAMP it’s /Applications/MAMP/conf/apache/httpd.conf.
When using virtual hosts the AllowOverride directive can be set individually for each virtual host. For instructions on configuring virtual hosts see Configuring Virtual Hosts in XAMPP on Mac OS X and Configuring Virtual Hosts in MAMP on Mac OS X.