gratzo Posted December 9, 2005 Report Share Posted December 9, 2005 trying to figure out why I'm reaching the "root" folder of my Uniform Server when I don't type in the "www" in front of the URL. Works fine when I type "www.mydomain.com", but when I type in "mydomain.com", it resolves to the root folder, and not the virtual host set up. Here is the detail behind this: Uniform Server v3.2vhost module installed and runningdynamic IP via dns.afraid.org For the dynamic DNS entries, I have entered both of these to forward to the Uniform Server:"mydomain.com""www.mydomain.com" I know that part is working, because when you enter the URL's, both addresses hit the server, only one hits the virtual host, the other hits the root. The virtual host entries in the config file are set to the following:NameVirtualHost * <VirtualHost *> Document Root /www/ ServerName localhost </VirtualHost> <VirtualHost *> Document Root /www/site1 ServerName www.mydomain.com </VirtualHost> I'm trying to do a rewrite with .htaccess to allow anyone to see the site on the virtual host with and without the "www". This is the code that I wrote into the .htaccess file, which obviously is NOT working correctly...and where I think I need the help Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC] RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L] I know in theory this should work, I just have something twisted in either the .htaccess file, or in the virtual host (httpd) Apache config file. Again, bottom line is (and I hope I'm not overcomplicating something that may be very simple) I'm just trying to resolve to the same place with and without "www" on my uniform server, with the virtual host running. Quote Link to comment Share on other sites More sharing options...
olajideolaolorun Posted December 9, 2005 Report Share Posted December 9, 2005 Try removing www from the VHost code and test it. Just the mydomain.com Quote Best Regards Olajide Olaolorun The Uniform Server Development Team Link to comment Share on other sites More sharing options...
gratzo Posted December 9, 2005 Author Report Share Posted December 9, 2005 Try removing www from the VHost code and test it. Just the mydomain.com 2037[/snapback] OK, after stumbling upon a 2002 post about Apache Server, here's what I found, and it's pretty similar to your instructions. For each virtual host, I had to create another set of instruction - (for kicks, I tried putting it all in one "Virtualhost" command, but it didn't work): This is the code that I put into the config file for the virtual host <VirtualHost *> DocumentRoot /www/site1 ServerName mydomain.com </VirtualHost> <VirtualHost *> DocumentRoot /www/site1 ServerAlias www.mydomain.com Redirect permanent / http://mydomain.com </VirtualHost> So you don't have to look back and forth at the former code, 1. I removed the "www" in the "ServerName" line2. Added the new "VirtualHost" section3. created "ServerAlias" with www.mydomain.com4. created the "Redirect permanent" line that points it to the new URL w/o the "www" Nothing needed to be done to the .htaccess file, in fact, I took it out to make sure there was not effect. Bottom line, this can be done via the Apache virtual domain and a simple bit of code in the config file. I hope this isn't just a fluke that it's working for me! Quote Link to comment Share on other sites More sharing options...
olajideolaolorun Posted December 10, 2005 Report Share Posted December 10, 2005 Seems OK Quote Best Regards Olajide Olaolorun The Uniform Server Development Team Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.