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
-
site speed
i use mid-quality pic and... but my site speed is low
On-Page Optimization | | zlbvasgabc
any suggestion?
my site is:
https://bandolini.ir/0 -
How do I reduce the amount of internal links on my site?
Hi, Can someone help me with reducing the amount of internal links on our site please? https://www.thepresentfinder.co.uk Thanks Charlie
On-Page Optimization | | The-Present-Finder0 -
Blog issue broken link
Taking Great Photographs Underwater May 25, 2015 By sdwellers@aol.com No comments yet florida keys, key largo diving Excuse my ignorance, I suspect this is an easy issue...but at the the top of each of my blog posts have what you see above....the "No Comments yet" tab is showing as a broken link 404 error...?Why? And how to fix?Thank you
On-Page Optimization | | sdwellers0 -
Use External Links
Hey 🙂 I noticed when analysing my pages that Moz gives the following advice about adding external links to my articles; "On any page specifically targeting a keyword, link externally to at least one (and possibly more than one) relevant, trusted resources as a best practice." As a small business I work pretty damn hard to get visitors to my website, so why on earth would I want to go to all that trouble just to send them away again to a trusted resouce? Secondly, what exactly is a "trusted resource"? Can I simply use search and use the top competitor, for example Moz or Wikipedia and does the anchor need to be an exact match or will a partial suffice. I say this because I already have the top spot for my longtail, so an exact match would be pointless. And lastly, I notice that pretty much all quality sites use external links to open in the same window i.e. not target=_blank, I never thought of it before today, but now that I'm considering using external linking in my articles I guess it's important to know the answer - i.e. Is this a best practice and does this give any seo benefit? Cheers, Lee :)
On-Page Optimization | | LeeC0 -
Linking from Subfolders
Hi, on my new theme there are a bunch of links from subfolders to pages that aren't in a sub folder, these pages also don't have links on the home page. Is there an seo issue when linking from subfolders to pages that aren't. I don't know if I'm wording this properly but what I mean is, mysite/project/project1 linking to mysite/post.
On-Page Optimization | | FPK0 -
How to use canonical with mobile site to main site
I am pretty sure that the mobile version of the main site needs to be the same canonical link from what I understand. I am trying to find good docuementation that supports this. Even better if its from Google or Matt Cutts. I have a main domain like http://www.mydomain.com the mobile version of this is http://www.mydomain.com/m/ Should my canonical be rel="canonical" href="http://www.mydomain.com"/> for both these pages?
On-Page Optimization | | cbielich0 -
The Value of Internal Links?
I have seen countless SEO "experts" suggest internal links are great to help the search engines find your content. I wonder if that is true any more. It seems like a sitemap would do a better job. I think tags may even hurt the content I want to Google to know as most important. I'm using Simple Tags on all of my WP sites. If it "sees" a word in the article that is also a tag it adds a link for that tag to a listing of all the articles with that tag. It only does this once per tag though. Going on the experts advice, I thought this was a good idea. But now, I'm thinking these tags reduce the value of links to my eBook or other content i want to feature. Which doesn't get tagged much since I don't promote it all that often on my site within content. I make it nearly impossible to miss it on the site though. 🙂 What I do see the tags doing is helping users find the content. So I do see it improving the bounce rate and giving uses an assist in finding more content about what they are looking for. I have tags marked as noindex follow. But I'm really considering now removing the links. I hate plugins anyway. 🙂 Seems I'm always finding another must have plugin though. Now I'm thinking I'd be better off to just add links manually into the content that I really want to feature. All these automatic links I'm generating can't be good. Thanks for your thoughts on this.
On-Page Optimization | | RustyF0 -
Link Product Thumb & Product Name with same anchor link?
We have an issue on one of our sites we're monitoring a campaign for that seems to have TOO many links on each page. I think the biggest reason is that each product listing on each category page has two separate anchor links into that page. One for the thumb and one for the name. So even though there should only be 60-70 links on each category page, that amount is being inflated because each product listing technically is being split into two separate links. Question is, should I place the thumbnail and name within the same anchor link? We do this on a lot of other sites we operate, but I'm not sure what's a better strategy. It would seem to me that it would be better to have a single anchor link that shares the thumb and product name.
On-Page Optimization | | AarcMediaGroup0