Hey Guys,
I want to redirect all incoming traffic to example.com to go to
www.example.com. How would I go about doing this? Here's what I have and it's not working. I resorted to javascript to fix the issue for now, but I'd prefer to have apache do the work.
Code:
<VirtualHost 12.34.56.78>
DocumentRoot /home/example/public_html
ServerName www.example.com
ServerAlias example.com
ScriptAlias /cgi-sys/ /var/www/cgi-sys/
ScriptAlias /cgi-bin/ /home/example/public_html/cgi-bin/
<Directory "/home/example/public_html/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
CustomLog logs/example.com-access_log combined
ErrorLog logs/example.com-error_log
</VirtualHost>
<VirtualHost example.com>
DocumentRoot /home/example/public_html
ServerName www.example.org
#ServerAlias example.org
Redirect permanent / http://www.example.com
</VirtualHost>
Another question, which would be the fastest alternative? Having php header you over, javascript check the
Code:
window.location.href.indexOf('www.example.com') != -1
or having apache do it?