Redirecting non-www pages to www ones
-
Hello:
I'm trying to consolidate all the link juice and see that some of my pages are linked to by using both www.mysite.com/whatever.html and mysite.com/whatever.html.
Is there a safe re-write rule that not just redirects non-www(s) to www(s), but designates the redirect as 301, so link juice will be transfered as well.If not RewriteRule, are there any other ways to accoplishe this?
And the last question: can this be solved by simply setting Preffered domain in google webmaster tools to display www URL?
Any help will be appreciated.
-
I also need to redirect my category pages from non-www to www. There is no option in Google web master tools for category pages, can you share with me exactly the code for my category page?????
-
thank you, that's what I need too, something I copy across multiple sites without having to change the domain URL every time. Appreciate your help.
-
also I use www. because it looks nicer, but its 6 of one and half a dozen of another....
-
The first one defines your url exactly so you can replace example.com with your own. The second one I used takes the http host variable from the header and fills it in for you.
In other words when a request is made to the site apache looks at the domain name and fills it in.
I use the second because it means there are large portions of my .htaccess file I can just copy and paste between multiple sites. As always there is more than one answer!!
Adam
-
what's the difference between:
RewriteRule (.) http://www.example.com/$1 [R=301,L] and
RewriteRule ^(.)$ http://www.%{HTTP_HOST}/$1 [R=301,L]any significance in using the root domain URL there instead of just www.%
-
This can be done within .htaccess. The code below should work -
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]The link juice will be transferred since it is a 301 redirect. And you can set your preferred domain within GWT but ideally you still want to use 301 redirects as well.
-
I would set the preferred domain in google webmaster tools to www. and do 301 redirects to www.
Webmaster tools will only effect how the link appears in search results, but not other external sources. Use the 301 redirect for that.
An example of one is
RewriteEngine On
non-WWW to WWW redirect
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]Hope it helps,
Adam
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
-
Is it ok to repeat a (focus) keyword used on a previous page, on a new page?
I am cataloguing the pages on our website in terms of which focus keyword has been used with the page. I've noticed that some pages repeated the same keyword / term. I've heard that it's not really good practice, as it's like telling google conflicting information, as the pages with the same keywords will be competing against each other. Is this correct information? If so, is the alternative to use various long-winded keywords instead? If not, meaning it's ok to repeat the keyword on different pages, is there a maximum recommended number of times that we want to repeat the word? Still new-ish to SEO, so any help is much appreciated! V.
Intermediate & Advanced SEO | | Vitzz1 -
Why rankings dropped from 2 page to 8th page and no penalization?
Dear Sirs, a client of mine for more than 7 years used to have his home page (www.egrecia.es) between 1st and 2nd page in the Google Serps and suddenly went down to 8 page. The keyword in question is "Viajes a Grecia". It has a good link profile as we have built links in good newspapers from Spain, and according to Moz it has a 99% on-page optimization for that keyword, why why why ??? What could I do to solve this? PD: It has more than 20 other keywords in 1st position, so why this one went so far down? Thank you in advance !
Intermediate & Advanced SEO | | Tintanus0 -
Disavow both www. and non www. version of site?
I just submitted my disavow file to Google after several months of work. A few months ago a saw a partial match unnatural link penalty in the www. version of my site's Search Console account. The penalty has since expired. Should I also upload the file to the non www. side of the Search Console account? No penalty ever appeared there.
Intermediate & Advanced SEO | | pajamalady0 -
Is it a problem to use a 301 redirect to a 404 error page, instead of serving directly a 404 page?
We are building URLs dynamically with apache rewrite.
Intermediate & Advanced SEO | | lcourse
When we detect that an URL is matching some valid patterns, we serve a script which then may detect that the combination of parameters in the URL does not exist. If this happens we produce a 301 redirect to another URL which serves a 404 error page, So my doubt is the following: Do I have to worry about not serving directly an 404, but redirecting (301) to a 404 page? Will this lead to the erroneous original URL staying longer in the google index than if I would serve directly a 404? Some context. It is a site with about 200.000 web pages and we have currently 90.000 404 errors reported in webmaster tools (even though only 600 detected last month).0 -
Two websites to merge into one - one has already been migrated - what about the second?
Hiya Mozzers, I have just been checking a website for duplication issues (this is a new website - they have just migrated across from old website to this new "main website"), and I found a wordpress blog on a different URL, duplicating the "main website"'s blog. Should I just close down this wordpress blog, 301 redirecting from the wordpress blog to the "main website"'s blog (equivalent blog posts to equivalent blog posts, with other indexed non-specific pages 301 redirected to "main website"'s blog homepage)? Thanks in advance for your help.
Intermediate & Advanced SEO | | McTaggart0 -
Www vs. non-www differences in crawl errors in Webmaster tools...
Hey All, I have been working on an eCommerce site for a while that to no avail, continues to make me want to hang myself. To make things worth the developers just do not understand SEO and it seems every change they make just messes up work we've already done. Job security I guess. Anywho,most recently we realized they had some major sitemap issues as almost 3000 pages were submitted by only 20 or so were indexed. Well, they updated the sitemap and although all the pages are properly indexing, I now have 5000+ "not found" crawl errors in the non-www version of WMT and almost none in the www version of the WMT account. Anyone have insight as to why this would be?
Intermediate & Advanced SEO | | RossFruin0 -
Duplicate titles but redirecting anyway (without redirects set up!!!)
Google has done a crawl of my site and is flagging up duplicate titles on my wordpress site. This appears to be due to the face that some posts are tagged in more than one category. I have just gone to make sure that each post just has one category and add redirects and I've noticed that all the duplicate title issues google has notified me about appear to redirect anyway. For example: http://www.musicliveuk.com/latest-news/live-music-boosts-australian-economy and http://www.musicliveuk.com/live-music/live-music-boosts-australian-economy have duplicate titles apparantly but the 1st url redirects to the 2nd one. I use the redirection plug in but have no redirection set up for that url so I'm a bit confused. And if they're redirecting anyway then why is google flagging up duplicate titles? Any help would be much appreciated.
Intermediate & Advanced SEO | | SamCUK1 -
Google swapped our website's long standing ranking home page for a less authoritative product page?
Our website has ranked for two variations of a keyword, one singular & the other plural in Google at #1 & #2 (for over a year). Keep in mind both links in serps were pointed to our home page. This year we targeted both variations of the keyword in PPC to a products landing page(still relevant to the keywords) within our website. After about 6 weeks, Google swapped out the long standing ranked home page links (p.a. 55) rank #1,2 with the ppc directed product page links (p.a. 01) and dropped us to #2 & #8 respectively in search results for the singular and plural version of the keyword. Would you consider this swapping of pages temporary, if the volume of traffic slowed on our product page?
Intermediate & Advanced SEO | | JingShack0