httpd Redirect / Rewrite .com to .org
- by David W
I am trying to redirect a www.example.com to www.example.org. I cannot figure out what I'm doing wrong.
I have ensured that mod_rewrite is enabled in httpd.conf with:
LoadModule rewrite_module modules/mod_rewrite.so
I further verify this by running:
httpd -M and getting  rewrite_module (shared) included in the results.
Later in the same httpd.conf file is the VirtualHost directive where I am trying to perform the rewrite:
<VirtualHost *:80>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ http://www.example.org/$1 [R=301,NC,L]
    ServerAdmin [email protected]
    DocumentRoot /var/www/html
    ServerName example.org
    ServerAlias www.example.org *.example.org
        <Directory "/var/www/html">
                Options Includes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
    ErrorLog /var/www/logs/error_log
    CustomLog /var/www/logs/access_log common
</VirtualHost>
As we can see, we are following SymLinks in the directory (which I believe is a requirement), AND we allow All Overrides (which meets another requirement). But obviously I'm still doing something wrong.
Can you spot it?