This question already has an answer here:
I have an apache2 server with 4 domain names point to my server's single IP address.
When I type in www.site1.com it serves pages from /home/eamorr/site1/index.php Same for www.site2.com, www.site3.com and www.site4.com
However, when I type in to the address bar of a browser without the www, it always redirects to site1.com!
site1.com -> site1.com site2.com -> site1.com site3.com -> site1.com site4.com -> site1.com
How do I configure apache to do the following:
site1.com -> site1.com site2.com -> site2.com site3.com -> site3.com site4.com -> site4.com
Here is my default config:
ServerAdmin firstname.lastname@example.org ServerName www.site1.com
DocumentRoot /home/eamorr/sites/site1.com/www DirectoryIndex index.php index.html <Directory /home/eamorr/sites/site1.com/www> Options Indexes FollowSymLinks MultiViews Options -Indexes AllowOverride all Order allow,deny allow from all php_value session.cookie_domain ".site1.com" #Added by EOH for redirection RewriteEngine on RewriteRule ^([^/.]+)/?$ driver.php?uname=$1 [L] </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined
I'd like to look at the domain name and then redirect to www.sitex.com. Is there an Apache rule to do this?
I hope someone can help. My SysAdmin/apache2 config skill aren't the best.
Many thanks in advance,