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
-
How long will old pages stay in Google's cache index. We have a new site that is two months old but we are seeing old pages even though we used 301 redirects.
Two months ago we launched a new website (same domain) and implemented 301 re-directs for all of the pages. Two months later we are still seeing old pages in Google's cache index. So how long should I tell the client this should take for them all to be removed in search?
Intermediate & Advanced SEO | | Liamis0 -
Should I do a redirect
Hello, I am building a new website with a new web address for subpages. The domain name stays the same. I am wondering if I should do redirect to the few pages that have an outside link going to them. I noticed all my subpage that don't have any external link have an authority of 18. I only have 1 subpage that has 2 external links and 1 of them has a spam score of 32 and then other one of 1. My website is about a 100 pages. What should I do for my subpages redirect , not redirect, redirect only the ones that have external links ? Thank you,
Intermediate & Advanced SEO | | seoanalytics0 -
URL structure - Page Path vs No Page Path
We are currently re building our URL structure for eccomerce websites. We have seen a lot of site removing the page path on product pages e.g. https://www.theiconic.co.nz/liberty-beach-blossom-shirt-680193.html versus what would normally be https://www.theiconic.co.nz/womens-clothing-tops/liberty-beach-blossom-shirt-680193.html Should we be removing the site page path for a product page to keep the url shorter or should we keep it? I can see that we would loose the hierarchy juice to a product page but not sure what is the right thing to do.
Intermediate & Advanced SEO | | Ashcastle0 -
Home page vs inner page?
do you believe that the advantage of targeting a search term on the home page is now worse off than before? as I understand it ctr is a big factor now And as far as i can see if two pages are equal on page etc the better ctr will win out, the issue with the home page is the serp stars cannot be used hence the ctr on a product page will be higher? I feel if you where able to get a home page up quicker (1 year instead of two) you still lost out in the end due to the product page winning on ctr? do you think this is correct?
Intermediate & Advanced SEO | | BobAnderson0 -
Should my back links go to home page or internal pages
Right now we rank on page 2 for many KWs, so should i now focus my attention on getting links to my home page to build domain authority or continue to direct links to the internal pages for specific KWs? I am about to write some articles for several good ranking sites and want to know whether to link my company name (same as domain name) or KW to the home page or use individual KWs to the internal pages - I am only allowed one link per article to my site. Thanks Ash
Intermediate & Advanced SEO | | AshShep10 -
Site less than 20 pages shows 1,400+ pages when crawled
Hello! I’m new to SEO, and have been soaking up as much as I can. I really love it, and feel like it could be a great fit for me – I love the challenge of figuring out the SEO puzzle, plus I have a copywriting/PR background, so I feel like that would be perfect for helping businesses get a great jump on their online competition. In fact, I was so excited about my newfound love of SEO that I offered to help a friend who owns a small business on his site. Once I started, though, I found myself hopelessly confused. The problem comes when I crawl the site. It was designed in Wordpress, and is really not very big (part of my goal in working with him was to help him get some great content added!) Even though there are only 11 pages – and 6 posts – for the entire site, when I use Screaming Frog to crawl it, it sees HUNDREDS of pages. It stops at 500, because that is the limit for their free version. In the campaign I started here at SEOmoz, and it says over 1,400 pages have been crawled…with something like 900 errors. Not good, right? So I've been trying to figure out the problem...when I look closer in Screaming Frog, I can see that some things are being repeated over and over. If I sort by the Title, the URLs look like they’re stuck in a loop somehow - one line will have /blog/category/postname…the next line will have /blog/category/category/postname…and the next line will have /blog/category/category/category/postname…and so on, with another /category/ added each time. So, with that, I have two questions Does anyone know what the problem is, and how to fix it? Do professional SEO people troubleshoot this kind of stuff all of the time? Is this the best place to get answers to questions like that? And if not, where is? Thanks so much in advance for your help! I’ve enjoyed reading all of the posts that are available here so far, it seems like a really excellent and helpful community...I'm looking forward to the day when I can actually answer the questions!! 🙂
Intermediate & Advanced SEO | | K.Walters0 -
Backlinking from a Canonical Page to the Non-Canonical Doman - Wrong Signals?
Hi Mozzers, Let's say you have www.mysite.com/page, which is a duplicate of www.yoursite.com/page. www.yousite.com/page has a rel canonical link identifying www.mysite.com/page as the original source. www.mysite.com/page has a followed backlink going towards www.yousite.com/home-page. mysite.com has a DA of 44
Intermediate & Advanced SEO | | Travis-W
yoursite.com has a DA of 33 Google has chosen to index www.yoursite.com/page instead of www.mysite.com/page. Is the followed backlink responsible for the wrong page being indexed? Thanks!0 -
404 with a Javascript Redirect to the index page...
I have a client that is wanting me to issue a 404 on her links that are no longer valid to a custom 404, pause for 10 seconds, then rediirect to the root page (or whatever other redirect logic she wants)...to me it seems trying to game googlebot this way is a "bad idea" Can anyone confirm/deny or offer up a better suggestion?
Intermediate & Advanced SEO | | JusinDuff0