Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: mydomain.com VS www.mydomain.com |
|
Author |
|
al0000
Joined: 29 Jan 2007 Posts: 24
|
Posted: Mon 15 Oct '07 22:44 Post subject: mydomain.com VS www.mydomain.com |
|
|
Hello,
My problem is simple.
I use a CMS which cannot handle sub domain independent cookies.
mydomain.com and www.mydomain.com create different cookie on the CMS.
Is there a way to redirect mydomain.com to www.mydomain.com using apache?
Thanx |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Tue 16 Oct '07 4:28 Post subject: |
|
|
mod_rewrite is built specifically for this
Enable the module
LoadModule rewrite_module modules/mod_rewrite.so
Add to your virtual host (if using) or just in your httpd.conf if not
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.mydomain.com/$1 [L,R]
Anyone attempting to go to http://mydomain.com will be redirected to http://www.mydomain.com
This is documented! |
|
Back to top |
|
|
|
|
|
|