The issue
I have installed a WordPress. I have turned on Pretty Permalinks (Post name). Any page other than the homepage is a 404 Not Found
. This seems to indicate a rewrite issue.
My set up
Ubunutu 14.04
Using localhost as my URL
My apache config is /etc/apache2/sites-available/000-default.conf
My wordpress is located at /var/www/wordpress/
My relevant htaccess is located at /var/www/wordpress/.htaccess
What I’ve tried
When I run a2enmod rewrite
I get
Module rewrite already enabled
My .htaccess
# 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
My 000-default.conf
file apache config
<Directory /var/www/wordpress/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I’ve tried all the answers at the canonical question for this.
How to enable mod_rewrite for Apache 2.2
My question
Why is my rewrite not working?
Steps to check proper vhost configuration:
Check if there is a “vhostname.conf” file in your “sites-available” directory. Then check if there is a valid symlink to that file in “sites-enabled” directory. You can create a missing site symlink by
a2ensite vhostname
. Open this file in an editor. It should contain something likeEnsure that the
DocumentRoot
folder has a matching<Directory /path/to/docroot>
block. Place into this blockAllowOverride All
or any selective permission you want to allow to be overridden in “.htaccess”.Ensure the rewrite module is enabled.
After modifying configurations don’t forget to restart/reload apache.
Check if the module and the vhost config was loaded.
I found that I needed to edit the apache config at
/etc/apache2/apache2.conf
and change the/var/www/
Directory toAllowOverride All
I would have thought that my
000-default.conf
would have overrode this but that was not the case and this fixed the issue.