Redirect domain from www on Apache

First locate the virtual host configuration file for Apache related to the domain, on FreeBSD it should be here:

  1. cd /usr/local/etc/apache/vh

Now add following in between the begin <VirtualHost *> and end </VirtualHost>

  1. RewriteEngine on                                                                                
  2. RewriteCond %{HTTP_HOST} ^www\.(.*)                                                            
  3. RewriteRule ^/(.*)$$1 [R=301]
This entry was posted in Web Development. Bookmark the permalink.

Leave a Reply