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:

cd /usr/local/etc/apache/vh

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

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^/(.*)$$1 [R=301]

This entry was posted in Web Development. Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.