Site wide 301 or canonical links.
-
Hi guys, I'd like add code to my header file to specify www. as opposed to just http:// for the canonical links across my entire site. How can I do this? I'd like it to be site wide code that I can just add to my header.php file which is included across the site.
-
Thanks Shane,
That was exactly what I was looking for!
-
Hi,
I believe what you are looking for is
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
If I read the post correctly as adding a sitewide canonical in header.php would not work, unless you actually programmed a php statement that all it did was add www, but this would only be a backup, if I was unable to do 301 in my opinion
Shane
-
Sorry I should have added I don't know the symbols to use to equate to any page starting with http:// should be fwd'ed to same page but http://www.
-
Hi Lodovico, thanks for your reply. I am fine with that, but do you know how I'd have to write the 301 in my .htaccess file to 301 every http://xxxxx.com page to http://www.xxxxx.com ?
-
Since the result you want is site wide, I would use a 301 redirect.
It's more radical, but you won't depend on the right header file to be included in all pages (i.e. you will be able to use different files, if you ever need it - e.g. to set up a landing page or mini site with its own template).
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
-
What should my site name be?
Hello, I'm a physical therapy clinic in Fort Myers, FL. Currently my website is named "Physical Therapy Fort Myers". My company name is Back In Motion Sport & Spine Physical Therapy. My question is, should I rename my site under my business name or is it OK to keep it as "physical therapy fort myers"?
On-Page Optimization | | backinmotion1230 -
Ecommerce Canonical Question
Hi all, first question (eek) Could I pick the brains of fellow users around an issue we are having with canonical urls on a magento website. At the moment we do not have these enabled as it seems to break our indexing. Cut a long story short, we have thousands of products but haven't rewritten many of the descriptions from the manufacturers yet and so have noindexed all the product pages (freeing them as we go). The goal, for now, is to pull in traffic via the filtering options we have on the site The goal, for now, is to pull in traffic via the filtering options we have on the site. For example, if you go to Dresses, there then are several filtering options which would allow you to choose a colour, shape and material - if you wished to filter that precisely. These filtering options are all crawlable and so we would then have a page that google could index for, for example, Green Lace Maxi Dress. All good there, few people search for specific products and a lot search for types of products so we are covered. To get back to the issue at hand. If we enable the canonical option on our magento plugin it will stop us from being able to target these terms. Whereas the filtering option would create domain.com/dress/green/maxi/lace with the page title of Green Lace Maxi Dress, if we enable the canonical part of the seo plugin the canonical link which would be added to the page would be - instantly removing our ability to rank for longer tail dress related searches (we are not going to compete with the big players on the premium terms, yet!). There are alternative plugins we can buy for magento to add the correct tag, however, if every page's canonical just points back it itself like this, is there really much point spending nearly $1000 on the 4 licences we would need to cover our range of sites. Is it really necessary, in this case, that we have a canonical for the product filtering? Sorry for the long post, hope it made sense. Thanks for any assistance.
On-Page Optimization | | DSCarl0 -
Inbound Linking from your own sites
Good evening, On each of the sites I have made, I have a link with the anchor text 'Build and Design by Christoper Davies' to my own website. This link is in the footer of every page each of all the sites. Should I have a 'no follow' rel added to these links, or does linking from all the sites (on all pages) help my ranking? I am concerned that having so many inbound links from the same sites, with the same anchor text may be doing me more damage than good.
On-Page Optimization | | chrisdavieswebdesign0 -
What on-site issue could be causing Moz to not detect internal links?
Hey guys, We've done a crawl and none of our internal links are showing up. Are there any on-page factors that would prevent Moz from being able to detect our internal links? Thanks!
On-Page Optimization | | ATMOSMarketing560 -
Internal Linking
I am trying to figure out internal linking. Please help me. Your "root domain" (the top level example.com) is the easiest to rank on a SERP. When you build Page Rank on this page, you want to make sure the majority of the PR goes into internal pages that matter. To do this you determine what internal pages are most important and put them on the menu bar. You then link to these pages in the body text, or via side bars. This will ensure that the PR is flowing from the root domain into the internal pages multiple times. The second part is to link from these secondary pages back to the main page. Correct? When you build back links on the internal page, you want to pass the PR back to the main page... Please discuss this...
On-Page Optimization | | JML11790 -
The "100 links/page recommendation" - Do Duplicate Links Count?
We have way too many links on our homepage. The PageRank Link Juice Calculator (www.ecreativeim.com/pagerank-link-juice-calculator.php) counts them to 300. But all of them are not unique, that is some links point to the same URL. So my question: does the "100 links/page recommendation" refer to all anchors on the page or only to unique link target URLs? I know "100" is just a standard recommendation.
On-Page Optimization | | TalkInThePark0 -
Canonical URLs and SEO
After publishing my new wordpress website my on page analysis shows two canonical urls on my homepage. In checking the source code the Yoast SEO plugin states my canoncial url is www.homepage.ca/ This is the only one showing. Having said this I do not add the trailing slash to anything on my url structure. Could this be why the on page analysis tool says there are 2? If so is there any way to resolve this?
On-Page Optimization | | casper4340 -
Number of Pages a Site Contains
Hi, How does the number of pages indexed from a single website affect that websites ability to compete in the SERPS? Cheers
On-Page Optimization | | Jurnii0