# Canonical Tags Fix Summary

**Last Updated:** 2026-01-20

## Overview

Fixed canonical tag issues identified in Google Search Console "Alternate page with proper canonical tag" report. Implemented redirects to strip tracking parameters and cleaned up duplicate canonical tag definitions.

## Issues Identified

### High Severity Issues

1. **URLs with tracking parameters not redirecting**
   - `/schichtplan?source=about_page`
   - `/digitale-personalakte?source=about_page`
   - `/dokumentenmanagement?source=about_page`
   - `/checklisten?utm_campaign=...&utm_source=...`
   - `/download/in-8-schritten-digital?trk=...`

2. **Multiple canonical tags defined**
   - `post.php` - Duplicate canonical tag after head.php
   - `webinar_sozialversicherung.php` - Duplicate canonical tag
   - `content_sozialversicherung.php` - Duplicate canonical tag
   - `tools_mehrwertsteuer_rechner.php` - Duplicate canonical tag

3. **Search parameters creating alternate pages**
   - `/tools?search={search_term_string}`
   - `/alternativen?search={search_term_string}`

4. **RSS feed URLs**
   - `/insights/author/vanessa/feed/` - Old WordPress feed URL

## Solutions Implemented

### 1. Added Redirect Rules in .htaccess

Added comprehensive redirect rules to strip tracking parameters from URLs:

**Location:** `.htaccess` lines 140-199

**Rules Added:**
- Strip tracking parameters from product pages (`source`, `utm_*`, `trk`, etc.)
- Strip tracking parameters from tools pages
- Strip search parameters from `/tools` and `/alternativen`
- Strip tracking parameters from download pages
- Strip tracking parameters from insights/blog pages
- Canonicalize pricing page parameters (`p=monthly/yearly` → clean `/preise`)
- Redirect RSS feed URLs (`/insights/author/{author}/feed/` → `/insights/`)

**Example Redirect Rule:**
```apache
# Strip tracking parameters from product pages
RewriteCond %{QUERY_STRING} ^(.*&)?(source|utm_source|utm_medium|utm_campaign|utm_term|utm_content|trk|ref|gclid|fbclid|hsa_|gad_source|leadSource|partner|signuptype)=[^&]*(&.*)?$ [NC]
RewriteCond %{REQUEST_URI} ^/(schichtplan|arbeitszeiterfassung|dokumentenmanagement|digitale-personalakte|checklisten|abwesenheiten|appstore|events|payroll|payroll-neu)$ [NC]
RewriteRule ^(.*)$ /$1? [R=301,L]
```

### 2. Removed Duplicate Canonical Tags

Fixed files with duplicate canonical tag definitions:

- `v2/pages/post.php` - Removed duplicate `<link rel="canonical">` after head.php
- `v2/pages/webinar_sozialversicherung.php` - Removed duplicate canonical tag
- `v2/pages/content_sozialversicherung.php` - Removed duplicate canonical tag
- `v2/pages/tools_mehrwertsteuer_rechner.php` - Removed duplicate canonical tag

**Pattern:** Set `$canonical_url` before including `head.php`, then let `head.php` output the canonical tag automatically.

### 3. Added RSS Feed Redirect

Added specific redirect rule for WordPress legacy RSS feed URLs:

```apache
# Author RSS feed redirects (WordPress legacy - redirect to blog index)
RewriteRule ^insights/author/([^/]+)/feed/?$ /insights/ [R=301,L]
```

## Files Modified

### .htaccess
- Added redirect rules for tracking parameter stripping (lines 140-199)
- Added RSS feed redirect rule (line 195)

### PHP Files
- `v2/pages/post.php` - Removed duplicate canonical tag
- `v2/pages/webinar_sozialversicherung.php` - Removed duplicate canonical tag
- `v2/pages/content_sozialversicherung.php` - Removed duplicate canonical tag
- `v2/pages/tools_mehrwertsteuer_rechner.php` - Removed duplicate canonical tag

### Documentation
- `docs/seo/CANONICAL_TAGS_BEST_PRACTICES.md` - Comprehensive best practices guide
- `v2/scripts/dev-helpers/audit-canonical-tags.py` - Audit script for canonical tags

## Expected Results

### Immediate Impact

1. **Tracking parameter URLs redirect to clean URLs**
   - `/schichtplan?source=about_page` → `/schichtplan` (301 redirect)
   - `/checklisten?utm_source=...` → `/checklisten` (301 redirect)

2. **Search parameter URLs redirect to clean URLs**
   - `/tools?search=test` → `/tools` (301 redirect)
   - `/alternativen?search=test` → `/alternativen` (301 redirect)

3. **Pricing page parameters redirect to clean URL**
   - `/preise?p=monthly` → `/preise` (301 redirect)
   - `/preise?p=yearly` → `/preise` (301 redirect)

4. **RSS feed URLs redirect**
   - `/insights/author/vanessa/feed/` → `/insights/` (301 redirect)

### Long-Term Impact

1. **Reduced alternate pages in Google Search Console**
   - Tracking parameter URLs will no longer appear as alternate pages
   - Clean URLs will be indexed instead

2. **Improved SEO**
   - Consolidated ranking signals to canonical URLs
   - Reduced crawl budget waste
   - Better indexing of important pages

3. **Cleaner Analytics**
   - Fewer duplicate URLs in analytics reports
   - Better tracking of actual page performance

## Testing Recommendations

### Manual Testing

1. **Test redirects:**
   ```bash
   curl -I "https://www.ordio.com/schichtplan?source=test"
   # Should return: HTTP/1.1 301 Moved Permanently
   # Location: /schichtplan
   ```

2. **Test canonical tags:**
   - View page source
   - Check for single `<link rel="canonical">` tag
   - Verify canonical URL is clean (no query parameters)

3. **Test in Google Search Console:**
   - Use URL Inspection tool
   - Check "User-declared canonical" matches expected URL
   - Verify redirects are working

### Automated Testing

Run the audit script:
```bash
python3 v2/scripts/dev-helpers/audit-canonical-tags.py
```

## Monitoring

### Google Search Console

Monitor the following reports:

1. **Coverage > Excluded**
   - Check "Alternate page with proper canonical tag" count
   - Should decrease over time as Google recrawls

2. **URL Inspection**
   - Test affected URLs
   - Verify canonical URLs are correct
   - Check redirect chains

### Analytics

Monitor:
- Redirect volumes (if tracking redirects)
- Page performance metrics
- User behavior on canonical vs. alternate URLs

## Next Steps

1. **Wait for Google recrawl** (1-2 weeks)
   - Google needs to recrawl affected URLs
   - Monitor Google Search Console for changes

2. **Validate fixes**
   - Run audit script periodically
   - Check Google Search Console reports
   - Test redirects in production

3. **Update internal links** (if needed)
   - Ensure internal links use clean URLs
   - Avoid linking to URLs with tracking parameters

4. **Document patterns**
   - Update team documentation
   - Add canonical tag patterns to coding guidelines

## Related Documentation

- [Canonical Tags Best Practices](./CANONICAL_TAGS_BEST_PRACTICES.md)
- [Landing Page Redirects](../../systems/landing-page-redirects/LANDING_PAGE_REDIRECTS.md)
- [Blog Templates](../../guides/blog-templates/BLOG_TEMPLATES.md)

## References

- [Google: Consolidate duplicate URLs](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls)
- [Google Search Console Help: Alternate page with proper canonical tag](https://support.google.com/webmasters/answer/7440203)
