Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I submitted a duplicate sitemap some time back to incorporate the www. addresses when I saw my site was not directing there when I typed it directly in the address bar. As I have edited my site and become better understanding of SEO I have done many 301 redirects for replaced pages, individually. No problem. Now I want to redirect the entire www. sitemap to my http sitemap. Must I redirect the entire mass of 4000+ urls individually or am I able to write a site level redirect... ie. site map directed to sitemap. The maps are identical except for the www. addition in the later one. The www. map has 105 listed urls while the http has 543. Any suggestions or knowledge concerning my best move???

share|improve this question
Do a simple search and replace? Search for http://www.mydomain.com replace with http://mydomain.com. Sorry maybe I'm missing something? – joesk Feb 12 '13 at 21:35
cool... thanks joesk... I'll give it a shot – thetripdaddy Feb 12 '13 at 21:39
up vote 4 down vote accepted

You can use a single rule to redirect the entire site. Both of the following methods will redirect the following urls properly

http://www.example.com/ -> http://example.com/
http://www.example.com/page.html -> http://example.com/page.html
http://www.example.com/directory/page.html -> http://example.com/directory/page.html

If you have access to your httpd.conf file, you can redirect the entire site using a virtual host directive. This is better for performance that using .htaccess and rewrite rules.

<VirtualHost *>
    ServerName www.example.com
    Redirect 301 / http://example.com/

If both your www and non-www hosts are served out of the same directory (and your host doesn't give you access to http.conf), you will need to use the following rewrite rules in your .htaccess file.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
share|improve this answer
Very cool... Thank you so much Stephen – thetripdaddy Feb 12 '13 at 23:10
I am going to enter this code:...RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^/(.*)$ http://%1/$1 [R=301,L] .... is it just like this or must I add some pertinent information anywhere???? – thetripdaddy Feb 12 '13 at 23:26
it worked.... thanks folks – thetripdaddy Feb 12 '13 at 23:29
Inside a per-directory .htaccess the RewriteRule pattern never starts with a / (slash) - yet thetripdaddy reports that this is working OK? – w3dk Feb 12 '13 at 23:56
If you don't start with the slash http://www.example.com/ gets redirected to http://example.com// – Stephen Ostermiller Feb 13 '13 at 0:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.