Web Hosting Talk







View Full Version : How can i redirect all addresses starting with www.domain.com to domain.com?


Factor
03-18-2003, 08:22 AM
How can i redirect all addresses starting with www.domain.com to domain.com?

With that i mean also that if http://www.domain.com/article.php is introduced it redirects to http://domain.com/article.php, not to http://domain.com only

PS: I imagine it's using .htaccess and mod_rewrite but no idea on how exactly.

Thanks in advance for your help.

Regards!

darksoul
03-18-2003, 08:45 AM
its dns
www IN CNAME @

Factor
03-18-2003, 08:52 AM
ok, thanks, now we are it, the same for *.domain.net and domain.net, to redirect to *.domain.com and domain.com?

Regards

Factor
03-18-2003, 04:08 PM
the www as cname didn't work as expected, the browser still shows www.domain.com as url, i want it to automatically *redirect* to domain.com without the www, not to show the same folder both in www.domain.com and domain.com

pyoor
03-18-2003, 04:20 PM
Try this... (replace $1 and 1.2.3.4 with your info)

<VirtualHost 1.2.3.4>
ServerName www.$1.com
DocumentRoot /home/sites/$1/public_html
RewriteEngine on
RewriteCond %{HTTP_HOST} !^1.2.3.4(:80)?$
RewriteCond %{HTTP_HOST} !^$1.com(:80)?$
RewriteRule ^/(.*) http://$1.com/$1 [L,R]
</VirtualHost>

---www.sekure.us---

Factor
03-18-2003, 04:25 PM
1.2.3.4 is the ip? or the id i give to virtual host?

Thanks for reply.

admin0
03-18-2003, 05:24 PM
Hi,

use the Redirect Permanent directive.

:homer: