Jeremy Phillips

Thoughts on technology, management and more

Enabling mod_rewrite with Apache 2.2 on FreeBSD

without comments

I have Wordpress Permalinks enabled but forgot to enable mod_rewrite after moving this site so everything was returning a 404. Since I moved this site back to my own server I had the pleasure of enabling mod_rewrite myself. Visions of a long night danced through my head as I thought I would have to recompile Apache in the process. Luckily it turns out that mod_rewrite is compiled in the Apache 2.2 port so all you have to do is make sure it’s enabled and allow overrides and enable options for the Wordpress home directory.

1) Make sure this line: LoadModule rewrite_module libexec /apache/mod_rewrite.so is present in httpd.conf by issuing the below command. As long as it returns the line you’re good to go there.

host# grep mod_rewrite /usr/local/etc/apache22/httpd.conf
LoadModule rewrite_module libexec/apache22/mod_rewrite.so
host#

2.) Change the directory settings in your VirtualHost statement. To use a real example, change this:

<VirtualHost *:80>
ServerName jeremyphillips.org
ServerAlias www.jeremyphillips.org
DocumentRoot /home/www/jeremyphillips.org
</VirtualHost>

To this:

<VirtualHost *:80>
ServerName jeremyphillips.org
ServerAlias www.jeremyphillips.org
DocumentRoot /home/www/jeremyphillips.org
<Directory /home/www/jeremyphillips.org>
Options All
AllowOverride All
</Directory>

</VirtualHost>

3.) Lastly restart Apache.

host# apachectl restart

Possibly Related Posts:

Written by Jeremy Phillips

July 24th, 2009 at 4:48 pm

Posted in Systems Administration

Tagged with ,

Leave a Reply

CommentLuv Enabled