troubleshooting Question

301 rewrite www.*.com to *.com

Avatar of zattz
zattz asked on
Apache Web Server
2 Comments1 Solution325 ViewsLast Modified:
Hi all,

I need to 301 redirect all requests from www.domain.com to domain.com

For one site (mysite.com) I would use the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.mysite\.com [nc]
RewriteRule (.*) http://mysite.com/$1 [R=301,L]

However, I need to do it in builk for all domains... IE: i need to rewrite www.* to *

It must work for all domains.. ie, com/info/net

I can't get the following to work:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [nc]
RewriteRule (.*) http://%1/$1 [R=301,L]
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros