Gplus E-mail
Home » Uncategorized » Enabling mod_rewrite with self-hosted WordPress site

Enabling mod_rewrite with self-hosted WordPress site


Permalinks and Pages in my new WordPress site (you’re looking at it!) didn’t work. I would publish a page and it’d all go well except the Page simply wasn’t¬†accessible¬†to the public Internet. I just got a 404 error. This was silly, since I knew WordPress didn’t keep folders in its installation directory, and instead generated those pages on the fly.

I’m listing my solutions to all of the little problems I’m having with WordPress (nothing major, I’m just a novice) because a lot of Google searches turn up junk for these things. And also for my future reference so I can save time down the road.


I had naively assumed that the WordPress install had updated my .htaccess file, but it hadn’t! This is what I made /.htaccess look like in the WordPress root directory:

 1|# BEGIN WordPress
 2| <IfModule mod_rewrite.c>
 3| RewriteEngine On
 4| RewriteBase /
 5| RewriteRule ^index\.php$ - [L]
 6| RewriteCond %{REQUEST_FILENAME} !-f
 7| RewriteCond %{REQUEST_FILENAME} !-d
 8| RewriteRule . /index.php [L]
 9| </IfModule>
10| # END WordPress


And the last bit, just so I remember, was to activate the Apache2 mod_rewrite module so that rewrite directives actually meant something. From the command line:

sudo a2enmod rewrite
/etc/init.d/apache2 restart


And everything is good!

© (c) Ryan E. Guerra 2000-2016