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
-
Category Page as Shopping Aggregator Page
Hi, I have been reviewing the info from Google on structured data for products and started to ponder.
Intermediate & Advanced SEO | | Alexcox6
https://developers.google.com/search/docs/data-types/products Here is the scenario.
You have a Category Page and it lists 8 products, each products shows an image, price and review rating. As the individual products pages are already marked up they display Rich Snippets in the serps.
I wonder how do we get the rich snippets for the category page. Now Google suggest a markup for shopping aggregator pages that lists a single product, along with information about different sellers offering that product but nothing for categories. My ponder is this, Can we use the shopping aggregator markup for category pages to achieve the coveted rich results (from and to price, average reviews)? Keen to hear from anyone who has had any thoughts on the matter or had already tried this.0 -
Client would like to 301 redirect the homepage to a category page
Hello MOZ Community!!! I would like your expert opinions on a scenario, please! My client is an ecommerce company, and currently has one of its category pages outranking its homepage for a few key phrases. The homepage, however, has a better conversion rate. So, the client is asking that we make the homepage the category URL, so http://www.theirsite.com/blue-clothes. The existing homepage URL - http://www.theirsite.com - would 301 REDIRECT to the category page - which would render the current version of the homepage. Therefore, there would be nothing, ZERO content, on the MAIN URL: http://www.theirsite.com Has anyone ever done this before? What are the pros and the cons of this practice? Here is my same client, for reference: https://moz.com/community/q/issue-with-category-ranking-on-page-1-vs-homepage-ranking-on-page-2
Intermediate & Advanced SEO | | accpar0 -
Base copy on 1 page, then adding a bit more for another page - potential duplicate content. What to do?
Hi all, We're creating a section for a client that is based on road trips - for example, New York to Toronto. We have a 3 day trip, a 5 day trip, a 7 day trip and a 10 day trip. The 3 day trip is the base, and then for the 5 day trip, we add another couple of stops, for the 7 day trip, we add a couple more stops and then for the 10 day trip, there might be two or three times the number of stops of the initial 3 day trip. However, the base content is similar - you start at New York, you finish in Toronto, you likely go through Niagara on all trips. It's not exact duplicate content, but it's similar content. I'm not sure how to look after it? The thoughts we have are:1) Use canonical tags 3,5,7 day trips to the 10 day trip.
Intermediate & Advanced SEO | | digitalhothouse
2) It's not exactly duplicate content, so just go with the content as it is We don't want to get hit by any penalty for duplicate content so just want to work out what you guys think is the best way to go about this. Thanks in advance!0 -
Pages that 301 redirect to a 404
We are going through a website redesign that involves changing URL's for the pages on our site. Currently all our pages are in the format domain.com/example.html and we are moving to stip off the .html file extension so it would just be domain.com/example We have thousands of pages as the site deals with news so building a redirect for each individual page isn't really feasible. My plan is to have a generic rewrite rule that redirects any page that ends .html to the stripped off version of this. A problem I can see with this is that it will also redirect pages that don't exist. So for example, domain.com/non-existant-page.html would 301 to domain.com/non-existant-page which would then return a 404 status. What would the SEO repercussions be for this? Obviously if a page doesn't exist already then it shouldn't show up in the search engine indexes and shouldn't be a problem but I'm a bit worried about how old pages that currently legitimately 404 will be treated when they start to 301 redirect to a 404 instead. Not sure if there any other potential issues from this that I've missed either? Thanks!
Intermediate & Advanced SEO | | sbb0240 -
Dealing with Redirects and iFrames - getting "product login" pages to rank
One of our most popular products has a very authoritative product page, which is great for marketing purposes, but not so much for current users. When current users search for "product x login" or "product x sign in", instead of getting to the login page, they see the product page - it adds a couple of clicks to their experience, which is not what we want. One of the problems is that the actual login page has barely any content, and the content that it does carry is wrapped around <iframes>. Due to political and security reasons, the web team is reluctant to make any changes to the page, and one of their arguments is that the login page actually ranks #1 for a few other products (at our company, the majority of logins originate from the same domain). </iframes> To add to the challenge - queries that do return the login page as #1 result (for some of our other products) actually do not reference the sign-in domain, but our old domain, which is now a 301 redirect to the sign-in domain. To make that clear - **Google is displaying the origin domain in SERPs, instead of displaying the destination domain. ** The question is - how do we get this popular product's login page to rank higher than the product page for "login" / "sign in" queries? I'm not even sure where we should point links to at this point - the actual sign in domain or the origin domain? I have the redirect chains and domain authority for all of the pages involved, including a few of our major competitors (who follow the same login format), and will be happy to share it privately with a Moz expert. I'd prefer not to make any more information publicly available, so please reach out via private message if you think you can help.
Intermediate & Advanced SEO | | leosaraceni0 -
My home page is not found by the "Grade a Page" tool
My home page as well as several important pages are not found by the Grade a Page tool. With our full https address I got this http://screencast.com/t/s1gESMlGwpa With just the www address I got this http://screencast.com/t/BMRHy36Ih https://www.joomlashack.com
Intermediate & Advanced SEO | | etabush
https://www.joomlashack.com/joomla-templates We recently lost a lot of positions for our most important keyword: Joomla Templates Please help us figure this out. Whats screwy with our site?0 -
Can a home page penalty cause a drop in rankings for all pages?
All my main keywords have dropped out of the SERPS. Could it be that the home page (the strongest) page has been devalued and therefore 'link juice' that used to spread throughout the site is no longer doing so. Would this cause all other pages to drop? I just can't understand how all my pages have lost rankings. The site is still indexed so there's no problem there.
Intermediate & Advanced SEO | | SamCUK0 -
Www or no www
OK. Let's get the obvious out of the way. We all know to 301 www to root, or root to www. However, my questions for discussion is, which is better? Is it better to redirect the root to www or redirect the www to the root? I ask this from the context of links. Because, even though my client's sites are being redirected in the .htaccess file, I note different PA, DA, and link counts for www vs no www. It appears to me it doesn't seem to matter in the social signal arena. What I am thinking is that redirecting the root to www is better because humans naturally link with www, so you take advantage this natural aspect. Agree or disagree? Are there any other considerations to worry about? Thanks,
Intermediate & Advanced SEO | | OnlineMarketingGuy
Guy P.S. My opinion is to call BS on link juice through 301s. It may help, but it is never as good as a link with no redirects.0