Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

301 rewrite www.*.com to *.com

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]
0
zattz
Asked:
zattz
1 Solution
 
jb1devCommented:
This works for me.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule (.*) http://%1/$1 [R=301,L]
0
 
zattzAuthor Commented:
thx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now