Hi, I'm running a dedicated server, and have access to the httpd.conf files.
I currently have two domains running on there, call it example.com and example.es - the latter simply redirects to example.com
What's weird is that the redirect for example.es sometimes works, and sometimes doesn't - it instead points to the DocRoot.
Here is the conf file:
NameVirtualHost 192.168.10.7:80
<VirtualHost 192.168.10.7:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster@example.com
<Directory "/home/htdocs">
AllowOverride All
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/home/htdocs"
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*) http://www.example.com [R=301]
# 301 redirect other domains over to .com
RewriteCond %{HTTP_HOST} ^example.es [NC]
RewriteCond %{REQUEST_URI} ^/
RewriteRule ^ http://www.example.com/ [L,R=301]
</VirtualHost>
Have I set this up correctly? I want to add a couple more domains that just do a 301 redirect to the example.com, and am concerned that even my first redirect is not functioning as expected :-(
A second question: I want to add another domain, running a separate site.
I tried adding a seperate VirtualHost like this:
<VirtualHost 192.168.10.7:80>
ServerName www.example2.com
ServerAlias example2.com
ServerAdmin webmaster@example2.com
<Directory "/home/htdocs2">
AllowOverride All
Options FollowSymLinks
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/home/htdocs2"
</VirtualHost>
But strangely, all that does is also point to the DocRoot of the FIRST virtual host (i.e. /home/htdocs instead of /home/htdocs2).
I'm a little out of my depth here, and would really appreciate any feedback on what I'm doing wrong. Many thanks!