Wildcard Redirects & Canonical Tags
-
I have an interesting situation.
Current URLs Example1:
www.domain.com/red-widgets-cid-1234.html
www.domain.com/red-widgets-cid-1234-1.html
www.domain.com/red-widgets-cid-1234-1-1.htmlCanonical on All Above URLs:
www.domain.com/red-widgets-cid-1234.htmlNew URL:
www.domain.com/red-widgets-cid-4567.htmlCurrent URLs Example2:
www.domain.com/red-widgets-cid-1234+10.html
www.domain.com/red-widgets-cid-1234+10-1.html
www.domain.com/red-widgets-cid-1234+10-1-1.htmlCanonical on All Above URLs:
www.domain.com/red-widgets-cid-1234+10.htmlNew URL:
www.domain.com/red-widgets-cid-6789.htmlCurrent URLs Example3:
www.domain.com/red-widgets-cid-1234+10+5.html
www.domain.com/red-widgets-cid-1234+10+5-1.html
www.domain.com/red-widgets-cid-1234+10+5-1-1.htmlCanonical on All Above URLs:
www.domain.com/red-widgets-cid-1234+10+5.htmlNew URL:
www.domain.com/american-red-widgets-cid-6789+5.htmlI want to make sure all variations of the above URL redirect to the new URLs. However, as you see in Example 3, we are dealing with variables that are passed on. (+5 in this case).
Question 1: What wildcard 301 redirect / regular expression can I use to tackle these ?
Question 2: If we redirect www.domain.com/red-widgets-cid-1234+10+5.html to www.domain.com/red-widgets-cid-6789+5.html and www.domain.com/red-widgets-cid-6789+5.html contains the canonical tag www.domain.com/american-red-widgets-cid-6789+5.html, any concerns or red flags here ?
-
Hi Nakul
Here is my stab at question 1, my methodology is trial and error so if any guru's want to take another shot at it please do so. Here is a nice 301 reference page lots of examples
RewriteEngine On
RewriteRule ^(.)_red-widgets-cid-1234.html$ www.domain.com/red-widgets-cid-4567.html [R=301]
#Example 2
RewriteRule ^(.)_red-widgets-cid-1234+10.html$ www.domain.com/red-widgets-cid-6789.html [R=301]
#Example 3
RewriteRule ^(.*)_red-widgets-cid-1234+10+5.html$ www.domain.com/american-red-widgets-cid-6789+5.html [R=301,L]We use ^ to denote start of string
We use $ to denote end of string
We use (.*)_ to look for a keyword. In the examples above we are looking for what each page name has in common
We use [R=301,L] for the Last rewrite, previous rules just use [R=301]
One thing that (maybe) needed is escaping the +signs in the string so like example 3 would be
^(.*)_red-widgets-cid-1234+10+5.html$ www.domain.com/american-red-widgets-cid-6789+5.html
Also I may missed a wildcard on some of these....
^(.)_red-widgets-cid-1234+10+5(.).html$ www.domain.com/american-red-widgets-cid-6789+5.html
Question 2:
Canonical to self canonical tag is okay.
This = That and That = That ..........Okay
This = That and That = The ..........Not OkayHope that puts you on track
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
-
Mobile Canonical Tag Issue
Hey so, For our site
Intermediate & Advanced SEO | | ggpaul562
we have the desktop version: www.site.com/product-name/product-code/ The mobile version www.site.com/mobile/product-name/product-code So...on the desktop version we'd have the following.. | | Now my question is, what do we do as far as canonicals on the actual mobile URL? Would it be this? | |
| | OR are we NOT supposed to have mobile canonical tags whatsoever since we've already added "rel alternate" ? Would like some clarificaiton. | | |0 -
Geo-Targeted Sub-Domains & Duplicate Content/Canonical
For background the sub domain structure here is inherited and commited to due to tech restrictions with some of our platforms. The brand I work with is splitting out their global site into regional sub sites (not too relevant but this is in order to display seasonal product in different hemispheres and to link to stores specific to the region). All sub-domains except EU will be geo-targeted to their relevant country. Regions and sub domains for reference: AU - Australia CA - Canada CH - Switzeraland EU - All Euro zone countries NZ - New Zealand US - United States This will be done with Wordpress multisite. The set up allows to publish content on one 'master' sub site and then decide which other sub sites to 'broadcast' to. Some content is specific to a sub-domain/region so no issue with duplicate and can set the sub-site version as canonical. However some content will appear on all sub-domains. au.example.com/awesome-content/ nz.example.com/awesome-content/ Now first question is since these domains are geo-targeted should I just have them all canonical to the version on that sub-domain? eg Or should I still signal the duplicate content with one canonical version? Essentially the top level example.com exists as a site only for publishing purposes - if a user lands on the top level example.com/awesome-content/ they are given a pop up to select region and redirected to the relevant sub-domain version. So I'm also unsure whether I want that content indexed at all?? I could make the top level example.com versions of all content be the canonical that all others point to eg. and rely on geo-targeting to have the right links show in the right search locations. I hope that's kind of clear?? Obviously I find it confusing and therefore hard to relay! Any feedback at all gratefully received. Cheers, Steve
Intermediate & Advanced SEO | | SteveHoney0 -
Canonical questions
Hi, We are working on a site that sells lots of variations of a certain type of product. (Car accessories) So lets say there are 5 products but each product will need a page for each car model so we will potentially have a lot of variations/pages. As there are a lot of car models, these pages will have pretty much the same content, apart from the heading and model details. So the structure will be something like this; Product 1 (landing page) Audi (model selection page)
Intermediate & Advanced SEO | | davidmaxwell
---Audi A1 (Model detail page)
---Audi A2 (Model detail page)
---Audi A3 (Model detail page) BMW (model selection page)
---BMW 1 Series (Model detail page)
---BMW 3 Series (Model detail page) Product 2 (landing page) Audi (model selection page)
---Audi A1 (Model detail page)
---Audi A2 (Model detail page)
---Audi A3 (Model detail page) BMW (model selection page)
etc
etc The structure is like this as we will be targeting each landing page for AdWords campaigns. As all of these pages could look very similar to search engines, will simply setting up each with a canonical be enough? Is there anything else we should do to ensure Google doesn't penalise for duplicate page content? Any thoughts or suggestions most welcome.
Thanks!0 -
Multilingual Redirection
Hey there awesome Mozzers, I have a site that it automatically redirects people by using geolocation ( i know that probably is not good ) to the various languages of the site. I just wanted to know Is 301 or 302 the best option? ( I've heard that for language re-directions 302 is the best case scenario ) My main page for example is www.example.com and it automatically redirects with a 301 to www.example.com/en for any language that is not there. What is the best case scenario? Leave it to redirect to /en or just leave it go to the root page www.example.com.
Intermediate & Advanced SEO | | Angelos_Savvaidis0 -
Rel canonical or redirect
Hi, my client has the following links pointing to the home page http://www.weddingrings.com/index.cfm http://www.weddingrings.com In this case would I use rel canonical or redirect?
Intermediate & Advanced SEO | | alexkatalkin0 -
Why does SEOmoz bot see duplicate pages despite I am using the canonical tag?
Hello here, today SEOmoz bot found and marked as "duplicate content" the following pages on my website: http://www.virtualsheetmusic.com/score/PatrickCollectionFlPf.html?tab=mp3 http://www.virtualsheetmusic.com/score/PatrickCollectionFlPf.html?tab=pdf And I am wondering why considering the fact I am using on both those pages a canonical tag pointing to the main product page below: http://www.virtualsheetmusic.com/score/PatrickCollectionFlPf.html Shouldn't SEOmoz bot follow the canonical directive and not report those two pages as duplicate? Thank you for any insights I am probably missing here!
Intermediate & Advanced SEO | | fablau0 -
Canonical Related question
I have a site where we have search and result pages, google webmaster tool was giving me duplicate content error for page 1 / 2 / 3 etc etc so i have added canonical on these pages like http://www.business2sell.com/businesses/california/ Is this is correct way of using canonical ?
Intermediate & Advanced SEO | | manish_khanna0 -
Should I use the canonical tag on all my mobile pages?
I've seen flavors of this question asked but did not see the exact response I was looking for. If I have a site at: www.site.com And I am creating a mobile version at: m.site.com (let's say a responsive design is not feasible at this time) And all the content on m.site.com is duplicative of the content on www.site.com What's the best way to handle that from an SEO perspective? Should I put a canonical tag on every mobile page pointing back to the www page? I assume that is better than a 'no index' tag on all pages of the mobile site?
Intermediate & Advanced SEO | | hbrown1080