The best way to redirect to www
-
What is the best way to redirect non www to www. I saw a lot of the solution. is this one ok?
RewriteCond %{HTTP_HOST} !^www.seomoz.org [NC]
RewriteRule (.*) http://www.seomoz.org/$1 [L,R=301]
-
Glad you got it. The code I like to use:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]Of course, replacing "domain" with your own domain.
Let us know if you need any more help.
-
yes, a lot of people don't know that you should verify both the www and non www version of your site in Google Webmaster Tools!
-
This works:
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
and to select preferred domain name first I need to add non www version of the website and that's why I received an error.
You help me a lot!
-
What is the server error you are getting with the .htaccess file?
You do indeed need to verify ownership of you site, it's real easy to do, it involves adding a small piece of code to your site. See http://support.google.com/webmasters/bin/answer.py?hl=en&answer=35179 -
I got server error with .htaccess file and in webmaster tool message "Part of the process of setting a preferred domain is to verify that you own http://
-
That solution works just fine.
It looks like the one from the SEOmoz "Redirection SEO Best Practices"
I've never had any problems with it.
Also to keep things tidy, be sure to tell Google Webmaster Tools that your preferred domain is **www.**domain.com
GWMT -> configuration -> settings -> display URL's as www.domain.com
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Apache .htaccess query string redirects
With regular redirect(s) the following URLs did not work, any ideas for the .htaccess code to make this work? http://www.domain.com/?view=featured redirect to http://www.domain.com/ http://www.domain.com/contact-us.html?view=message&layout=message&pf=1&redirect_on_success= to http://www.domain.com/contact-us.html and http://www.domain.com/login.html?return=aW5kZXgucGhwP29wdGlvbj1jb21fcGhvY2Fkb3dubG9hZCZ2aWV3PWNhdGVnb3J5JmlkPTEyOmNvbWJpbmUtZXZhbHVhdGlvbiZJdGVtaWQ9NzM4 to http://www.domain.com/login.htm Thanks guys! 🙂
On-Page Optimization | | vmialik0 -
www vs no-www duplicate which should I use
site is no-www I caught this in archives. Will this by my fix? Mike Davis Online Marketing Manager at McKesson May 22, 2013 Easy fix: in your .htaccess file, use this RewriteEngine On
On-Page Optimization | | touristips
RewriteCond %{HTTP_HOST} !^domain.com
RewriteRule (.*) http://domain.com/$1 [R=301,L] Remember to replace domain.com with your domain name.
Enjoy!0 -
Best Practice: Should We Always Make No-Follow for External Links from Blogs?
Hi Mozers, I have few questions: 1. If I am allowing advertising on my blog and people advertising by placing Ads, Contextual links in Posts, Should I make them No-Follow? If Yes, then I might lose a good amount of income coming from Advertising. What is the best practice without loosing Organic rankings. 2. If I make all the External Links No-Follow (simple wordpress plugin can do), then I may not have anyone to advertise on my blog. What is the advantage that I am going to get? 3. Keeping the Do-Follow on all external links, how it will effect my blog? when there is no spam and all quality content on the blog. Thank you
On-Page Optimization | | mutantspy0 -
Lost Page Rank after directing http:// to WWW?
Hi I am trying to redirect all the non www urls to WWW. After I redirected them, most of my category page PR are dropped to 0. Can someone please tell me if this is the normal after effect after the redirect? Example url: this is PR2 before the redirect http://www.ilovebodykits.com/category/95/Body_Kits_Front_Bumpers.html
On-Page Optimization | | ilovebodykits0 -
Temp redirects of homepage URLs
Working on a site for a client and the CMS provider has all variants of their domain (.co.uk & .com and / and http:// etc) temp redirecting to the /default.aspx homepage. I know in theory that this means no Google Juice is being passed to the final location page, does this mean that all backlinks that point to their domain are not actually passing Juice onto the homepage? Thanks
On-Page Optimization | | Switch_Digital0 -
What's the best way to name an image for SEO?
Hi Guys,
On-Page Optimization | | krseo
I'm thinking about images and SEO. What's the best way for naming and using images in HTML Code? For example: Image-Name: keyword-keyword2-keyword3.jpg or keywordkeyword2keyword3.jpg ?
How many Keywords should I use max for a picture? And also do you use the alt tag as description of the image and the title tag or only the alt tag? If you use the title, what do you use it for? Maybe someone can copy a HTML-Code example for me 😉 Thank you 🙂
Alex0 -
How best to approach archiving badly optimised content
I signed up SEO Moz about a month ago as i'm currently rebuilding my site from scratch and wanted to learn from current mistakes. At present I use the forum software Invision Power Board to manage my site and one thing i've learnt is that it is terrible for SEO, there are so many thousands of errors listed by the crawler that it's not even worth trying to fix it. However because it has 5 or 6 years worth of content alot of which is on Google I don't want to totally remove it, rather I would prefer to archive it of with a big banner at the top letting anybody that visits it know that it's no longer in use and pointing them to the frontpage. I should note that it is in a subfolder already so the location of any of the links won't be changed. So the few questions I have are: The forum index has alot of link juice and I would like to redirect that to the new forum index, however for archive purposes the old index still needs to be accessible. Some topics are very popular and appear high in Google and have alot of backlinks. The important information in these forum topics will be available elsewhere on the new rebuilt site. Again I would like to redirect both link juice and users to the new page, however being a forum topic there are tens or hundreds of pages of old comments that need to still be accessible for reference. There are bound to be duplicate meta title and description issues with new similarly named categories appearing both on the new site and the old forum, is this going to be that much of a problem? So really what i'm asking is, how should I go about archiving this of without destroying content and rankings, but still making sure that the new stuff is getting the right exposure both to users and search engines alike?
On-Page Optimization | | freezedriedmedia0 -
Best article about internal linking structure?
Hi! Could you please recommend me a good and deep article about best practises in internal linking structure? I need to rethink the structure of a big site (lucky me it's very hierarchical) and I would like to have a look at some great articles about this to consolidate some ideas and have some new ones. I've read some but I would like some recommendations 🙂 Some articles about information architecture would be appreciated as well! Thanks!
On-Page Optimization | | jorgediaz0