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
-
301 and the base URL
Hi, please bear with me as I'm pretty new to all this! I've my base URL but obviously want to add keywords to it for seo purposes. Should I redirect from the base URL to the URL with the keywords appended? So my landing page goes from say www.moz.com to www.moz.com/keywords-here. If I do that, should I replicate all the meta data (descriptions etc) on the original landing page? Or does it not matter? Thanks, Nick
On-Page Optimization | | nickwoodward0 -
301 to canonical
I'm doing some work on a website, they have a very popular product search where you enter a specific part code (6 digits) and it takes you to the product. So for example Search: 123456 Page redirected to domain.com/product/123456 With a canonical of domain.com/product/this-is-the-product-title Would it be beneficial to redirect from /product/123456 to /product/this-is-the-product-title Google seems to be indexing both versions. For some of these products a reasonable amount of links are built.
On-Page Optimization | | ThomasHarvey0 -
Will canonical tag on non-copy content harm my site?
Days ago I added rel=canonical tags on my site. For the post pages, I add canonical tag on both post page (www.exmample.com/post.html) and comment page (www.exmample.com/post-sms.html), all the canonical tags are pointing to post page, but in fact there are only comments on the comment page. For product pages, I add the canonical tags on both product info page, download page, and order page, all of them are pointing to the info page, while in fact they are displaying different content. I no-indexed the comment page, download page, and order page for a long time. After I added the canonical tags, the traffics dropped (not hugely but slowly and steadily). Are my actions harming my site? Is this a normal flux after adding codes to the entire site, or it's the bad outcome for wrong SEO actions? PS: I can't change the site structure, so it's not possible to combine post and comment pages into one, so do the product pages. Thank you guys
On-Page Optimization | | JonnyGreenwood0 -
Too Many On-Page Links
Hi, I did a SEOmoz campaign and got results today, One of the results is Too "Many On-Page Links" when i am drilling down, i see that that's include inside links. for example, i sale food, i have my main department window - inside i have 30 products - each product is linked to a detailed page about the product. so automatically i have 30 links - not including all the others in this page, and i easily get over 100 and even sometimes 200 is this a big issue? does it damages my SEO? If yes, is there a way to write the HTML in a way that internal links like that wont be counted? Thank you SEOWiseUs
On-Page Optimization | | iivgi0 -
What is on page links?
Hi - i would like to know exactly what an on page link is? i understand the linking system however cant work what exactly what an on page link is? Thanks
On-Page Optimization | | OasisLandDevelopment0 -
Are My footer links bad?
I started working here recently, they said the footer links were to help with navigation of their most popular products. I am curious after reading http://www.seomoz.org/blog/internal-linking-strategies-for-2012-and-beyond if having these footer links could hurt the ranking of those key words after the penguin update. I am looking more into the analytics, and have not seen a negative impact yet.
On-Page Optimization | | DoRM0 -
Number of links in breadcrumb
Does google take the number of links in breadcrumb as a indicator to the depth of the page in the site structure? That will mean that a page with 5 links in the breadcrumb is a page very far away from the index, therefore a less important page.
On-Page Optimization | | seo.academy0 -
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