I’ve been having some trouble trying to get mod_rewrite to redirect www.domain.com to domain.com. I’m not sure if the subdomain logic in the virtual host has anything to do with that.
This works but it puts a // at the end of the domain. Even if I go to something like http://www.domain.com/folder/page.htm it would redirect to http://domain.com//folder/page.htm. This also makes me think about HTTPS requests, if it would even work with those or not. I haven’t tested this on a SSL enabled site yet.
Okay well I got this to work with the SSL site that I was testing. I just copied the mod_rewrite rule into the port 443 virtual host for the site and changed http to https… This wasn’t loading the SSL pages for me at first because the config file for the application running the site still had www set for the SSL connection… it had nothing to do with the mod_rewrite rule.
And if you want to redirect it the other way, domain.com to www.domain.com it should be self-explanatory. I’m just redirecting it all to domain.com because that IS that ServerName in the virtual host file. I also request certificates under the common name domain.com rather than www.domain.com. Just a personal preference.
My question still is if this is going to interfere with any of the InterWorx subdomain logic in the virtual host files?