Advertisement

[Apache] make yes.com to www.yes.com

Started by July 13, 2006 01:16 PM
1 comment, last by Brother Bob 18 years, 4 months ago
As the title suggests, is there a way to make everyone who comes to to my site using the name mydomain.com to go to www.mydomain.com? Because I am getting &#106avascript errors and it seems like the browser counts www.mydomain.com and mydomain.com as two different domains.
You might need to set up a virtual host in your httpd.conf
Advertisement
Can be done using the rewrite engine module.
RewriteEngine OnRewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

I have it in a .htaccess file in the root directory, but should work in httpd.conf aswell. When someone visists mydomain.com/blah/blah, the HTTP response code 301 (file moved) is sent back with the new address www.mydomain.com/blah/blah. It changes the host name and preserves any directory and file structure in the original request. The new web page is automatically asked for by the web browser, so the change is pretty much done without the user noticing anything.

This topic is closed to new replies.

Advertisement