I would like my site to direct all traffic from http://www.example.com and example.com or anythingelse.example.com to this.example.com This is what I have in my .htaccess file which is located in /www/example.com/public_html directory
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://this.example.com/ [R=301,L]
It works when I visit this.example.com but when I visit http://example.com it redirects me to example.com/public_html and http://www.example.com doesn’t redirect at all! However this.example.com works. This is my virtual host setting:
<VirtualHost 12.34.56.78:80>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias this.example.com
ServerAlias www.example.com
DocumentRoot /srv/www/example.com/public_html/
ErrorLog /srv/www/example.com/logs/error.log
CustomLog /srv/www/example.com/logs/access.log combined
</VirtualHost>
I’ve noticed in my error log when I visit: example.com it says “File does not exist: /srv/www/example.com/public_html/public_html”
Solution provided by requinix on devshed