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
-
ASP Canonical and Internal Linking
Hello - I'm working with a large ASP website and trying to troubleshoot issues I believe might be related to how the canonical element is used. On page - all internal links, including navigation links, use the following format (uppercase) - website.com**/F**older/Folder/Product . So, any page navigated to will always display the uppercase version of the URL. And, all of these pages have the canonical tag pointing to the lowercase version of the URL. The pages included in Google's index are all lowercase versions of the URL like this - website.com**/f**older/folder/product . My concern is that a lot of internal authority flow is being impacted/negated because all internal links point to the uppercase versions of URLs and all those pages reference the lowercase version URL in the canonical reference. Is this a valid concern?
On-Page Optimization | | LA_Steve0 -
Why ranks my site so bad?
hello together, i think, that you read questions like this very often, but i hope someone has some good ideas for me. https://goo.gl/3iOmcqy with the keyword "sophos sg 210" we rank very bad. But i don't know why 😞 We have trust elements, a very good "avergage time on page" unique content... But i don't know, what can we make better 😞 Thx you so much
On-Page Optimization | | enbitcon0 -
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 -
I'm using Canonical URL but still receiving message - Appropriate Use of Rel Canonical
Hello, I checked my site and it looks like everything is setup correctly for canonical url but I keep getting the message that it's not. Am I doing something wrong? SORRY I FIGURED IT OUT! THANK YOU! HOW DO I DELETE THIS?
On-Page Optimization | | seohlp440 -
Internal linking question
I have a Q&A site which I am struggling to get ranking well in Google. I had a few questions 1. Should I be doing some internal linking and if so how is it best to do this? Should I go back into users questions and change certain keywords to links if applicable? 2. Should I be nofollowing the index pages ie /p1 /p2 of discussions? 3. If anyone has chance to look at the site and let me know if there is anything else I am doing wrong I would be really grateful. Thanks
On-Page Optimization | | oliboy0 -
Locating broken links on site?
Hey guys, I'm using Screaming Frog to help locate some broken links on a client's site and I've managed to pick up two. However, I can't seem to find whereabouts they're located on the site in order to fix them! Is there a way I can do this? Cheers!
On-Page Optimization | | Webrevolve0 -
Which Blog Platform to link to an eCommerce site is best?
I just hired a content writer to blog on my site, but I want to make sure I have the right blog set up properly before doing so. I currently have my blog on my own domain. http://alturl.com/ixd7p It's a pretty crappy blog, to be quite frank. (The link to the blog is in the footer). It doesn't allow me to change category titles so it's throwing duplicate content - not good. I am seriously considering getting a self hosted Wordpress blog and linking that to my site instead at 3dcart- so it will be blog.domainname.comMy CONCERN.... I always heard that it's best to have the blog right right on the eCommerce site (just as I have it now) because it keeps feeding the domain fresh content. If I have a self hosted Wordpress blog and have it linked to my site, will it still feed my site fresh content?
On-Page Optimization | | tutugirl0 -
Seasonal site structure
Bit of a complicated one for anyone who likes a challenge.. We sell a range of products which are very seasonal, so therefore have a seasonal section within the store with the products categorized into their relevant categories. In additon to this i wanted to also create a feature of each season so in effect pull forward on to a new tab the relevant season ie: Valentine so that customers didn't have to hunt for the products by going via seasonal shop etc The problem is that my site urls display last-category/product-title so in effect as the seasons change these urls will be deleted. They do remain elsewhere in our catalogue.. Does this make sense?
On-Page Optimization | | LadyApollo0