🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

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

Started by
1 comment, last by Brother Bob 17 years, 12 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.
Advertisement
You might need to set up a virtual host in your httpd.conf
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