Title: Canonical Attachments
Author: hivedigital
Published: <strong>Januaro 19, 2017</strong>
Last modified: Aŭgusto 25, 2025

---

Priserĉi kromprogramojn

![](https://ps.w.org/canonical-attachments/assets/banner-772x250.jpg?rev=1582167)

![](https://ps.w.org/canonical-attachments/assets/icon-256x256.png?rev=1582167)

# Canonical Attachments

 De [hivedigital](https://profiles.wordpress.org/hivedigital/)

[Elŝuti](https://downloads.wordpress.org/plugin/canonical-attachments.1.8.zip)

 * [Detaloj](https://eo.wordpress.org/plugins/canonical-attachments/#description)
 * [Pritaksoj](https://eo.wordpress.org/plugins/canonical-attachments/#reviews)
 *  [Instalo](https://eo.wordpress.org/plugins/canonical-attachments/#installation)
 * [Programado](https://eo.wordpress.org/plugins/canonical-attachments/#developers)

 [Helpo](https://wordpress.org/support/plugin/canonical-attachments/)

## Priskribo

This plugin was developed to allow canonical tags as response headers to be created
via htaccess for attachment files such as pdfs and docs.

The plugin:

 * Generates an htaccess file to manage the wp-content/uploads directory where these
   files are being uploaded
 * Updates the htaccess file with canonical tags which are delivered via a header
   when the attachment is called
 * Creates a dashboard where you can easily filter and find attachments without 
   canonicals or that are not attached to a post.
 * Creates a dashboard where you can easily attach a file to its parent post (one
   at a time or in bulk) or manually add/remove a canonical tag for a file
 * Allows you to add a canonical url from the media file in the library or when 
   you upload
 * Creates a dashboard to edit the .htacess file directly for the uploads directory
   in case there are additional files in the directory that were uploaded outside
   of wordpress (e.g. during a site migration)

**The challenge:** Analytics software such as Google Analytics, cannot track a user
that enters a website via a pdf file in Google search results. Files cannot have
a standard canonical tag added in the <head> and instead the canonical tag has to
be added via an http header when the file is requested from the server. In order
to accomplish this, we need to have an htaccess file listening for a request to 
that file, and then sending the header.

**Expected outcome:** PDF files and other attachments will be replaced in search
results with the post or page counterparts, and we will be able to measure the traffic
to those pages and provide calls to action for downloading the file, submitting 
contact forms, etc. Note: Canonical tags do not force a search engine to index one
url vs. another, but act as a guideline/request to the search engine. As long as
the attachment content is similar to the canonical URL, you should have no problem
encouraging the search engines to choose the correct version.

### Future Features and Development

Based on the feedback, we hope to continue developing additional features to support
user requests. Current future feature ideas include:

 * Automatic canonicalization of non-image files to attached post
 * Integration with non-apache servers
 * Canonical builder for non-wordpress media files
 * Option to bulk delete canonical associations and delete htaccess on uninstall

## Ekrankopioj

 * [[
 * Plugin dashboard with options for bulk editing or individual editing to create
   canonicals for attachment files, and easy filters to drill down to those files
   needing fixed!
 * [[
 * Main page with options explained / highlighted
 * [[
 * Editor page for the uploads .htaccess file
 * [[
 * Media pages have an input field for the canonical URL
 * [[
 * Option to enter canonical url when you upload a file

## Instalo

This section describes how to install the plugin and get it working.

 1. Search for “Canonical Attachments” from the Add Plugins page and click install
 2. Alternatively: Upload `canonical-attachements.zip` to the `/wp-content/plugins/`
    directory
 3. Activate the plugin through the ‘Plugins’ menu in WordPress
 4. Enjoy!

## OD

### Will this work on wordpress installs that do not use apache server

No. This plugin only works for wordpress installations on servers running apache,
as it is depending on writing the rules to the .htaccess file.

### Do I have to manually create the .htaccess file in the uploads directory?

The plugin will need to be able to write to the directory in order to work. When
you install the plugin, it will create the .htaccess file with the proper permissions.

### What happens to the .htaccess file if I uninstall the plugin

As there may be other items in the htaccess file that are important, uninstalling
this plugin does not remove the .htaccess file. You will have to do this manually.
It is important to note that uninstalling this plugin does not remove any content
of the htaccess file. If you wish to remove canonicals, you should use the bulk 
editor or manually edit the .htaccess file using the editor option. When you remove
by manually editing the htaccess file, the associations will still exist in the 
wordpress database as an option for that media item, but since they are not in the.
htaccess file, they will be “useless”. This is why it is recommended to use the 
bulk editor vs. editing htaccess directly.

### Why is there an option to edit the .htaccess directly?

In some instances there may be files outside of wordpress’s database that you wish
to canonical, so we wanted to make it accessible for adding those items. The most
likely case for this would be if you migrated to wordpress and manually moved a 
directory or files into the uploads folder vs. uplaoding through wordpress. Future
iterations of this plugin might include a way to better manage non wordpress linked
media files.

### Some of my media files aren’t attached to a post, what happened?

This has nothing to do with our plugin, but occurs when you upload media files when
you are not editing / creating a post. The wordpress library has a filter for unattached
media items, and you can attach them manually there. Our editor does not require
the media item be attached to a post, it just makes it possible to use the bulk 
feature to attach vs. having to do it one at a time. You can also use the post finder
from the “attach media” option in our bulk editor.

### Who built this awesome plugin?

This plugin was developed by the good folks at [Hive Digital](https://www.hivedigital.com/?utm_source=wordpress&utm_campaign=canonical-attachments&utm_medium=plugin-page)

## Pritaksoj

![](https://secure.gravatar.com/avatar/14a7d0ba768c5385189155903235f84d80ed14beeb46e6beaae5f49a921af4a3?
s=60&d=retro&r=g)

### 󠀁[Does what it should do](https://wordpress.org/support/topic/does-what-it-should-do-14/)󠁿

 [chidoti](https://profiles.wordpress.org/chidoti/) Aŭgusto 8, 2018

Great and unique plugin for those who are into SEO. Special thanks for the support
from the developer.

![](https://secure.gravatar.com/avatar/6b43e09412385420cbf4ecae1a80f1587539596f1e61cf2c6cb19683cde2a47d?
s=60&d=retro&r=g)

### 󠀁[Works exactly as expected!](https://wordpress.org/support/topic/works-exactly-as-expected-18/)󠁿

 [Jake Bohall](https://profiles.wordpress.org/jblifestyles/) Februaro 7, 2017

The plugin is easy to install and the admin interface makes it super simple to quickly
add the canonical tag to pdf files. As one of the developers of the plugin, I am
biased, but … I can honestly say that it accomplishes everything that I need.

 [ Legi ĉiujn 2 pritaksojn ](https://wordpress.org/support/plugin/canonical-attachments/reviews/)

## Kontribuantoj k. programistoj

“Canonical Attachments” estas liberkoda programo. La sekvaj homoj kontribuis al 
la kromprogramo.

Kontribuantoj

 *   [ hivedigital ](https://profiles.wordpress.org/hivedigital/)
 *   [ Jake Bohall ](https://profiles.wordpress.org/jblifestyles/)
 *   [ Ionut Boicu ](https://profiles.wordpress.org/licuriciul/)

[Traduki “Canonical Attachments” en vian lingvon.](https://translate.wordpress.org/projects/wp-plugins/canonical-attachments)

### Ĉu interesita en programado?

[Browse the code](https://plugins.trac.wordpress.org/browser/canonical-attachments/),
check out the [SVN repository](https://plugins.svn.wordpress.org/canonical-attachments/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/canonical-attachments/)
by [RSS](https://plugins.trac.wordpress.org/log/canonical-attachments/?limit=100&mode=stop_on_copy&format=rss).

## Ŝanĝprotokolo

#### 1.8

 * Testing with latest version of wordpress
 * Testing with PHP 8.3
 * Fixing warnings from PHP 8.3
 * Changing author logo
 * Thank you to @licuriciul for update/testing for latest versions

#### 1.7

 * Testing with latest version of wordpress
 * Bug Fix .. thank you @bnovembit for pointing out the issues with return inside
   of if statement.

#### 1.6

 * Testing with latest version of wordpress

#### 1.5

 * Bug Fix .. thank you @dglingren for pointing out the return $post issues
 * Updated screenshots to highlight new functionality
 * Shortcut to plugin settings / options page

#### 1.4

 * Bug Fix .. thank you @philippmuenchen for pointing this out!

#### 1.3

 * Added options to filter the main canonical page
 * Added options to attach/detach media to posts

#### 1.2

 * Security update for $_POST data

#### 1.1

 * Fixing function names with prefix
 * More security updates
 * Addressing issue with file location requests to allow for non-standard installs

#### 1.0

 * Polishing plugin for submission to wordpress repository
 * Security Fix: Requiring nonces for form submissions

#### .5

 * Bug Fix: Delete canonical when media file is deleted
 * Security Fix: Checks user permissions for access to bulk editing tools

#### .1

 * Initial plugin creation

## Metadatumoj

 *  Version **1.8**
 *  Last updated **antaŭ 8 monatoj**
 *  Active installations **300+**
 *  WordPress version ** 4.5.1 or higher **
 *  Tested up to **6.8.5**
 *  Language
 * [English (US)](https://wordpress.org/plugins/canonical-attachments/)
 * Tags
 * [attachments](https://eo.wordpress.org/plugins/tags/attachments/)[canonical](https://eo.wordpress.org/plugins/tags/canonical/)
   [pdf](https://eo.wordpress.org/plugins/tags/pdf/)
 *  [Altnivela rigardo](https://eo.wordpress.org/plugins/canonical-attachments/advanced/)

## Pritaksoj

 5 out of 5 stars.

 *  [  2 5-star reviews     ](https://wordpress.org/support/plugin/canonical-attachments/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/canonical-attachments/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/canonical-attachments/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/canonical-attachments/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/canonical-attachments/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/canonical-attachments/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/canonical-attachments/reviews/)

## Kontribuantoj

 *   [ hivedigital ](https://profiles.wordpress.org/hivedigital/)
 *   [ Jake Bohall ](https://profiles.wordpress.org/jblifestyles/)
 *   [ Ionut Boicu ](https://profiles.wordpress.org/licuriciul/)

## Helpo

Got something to say? Need help?

 [Vidi helpforumon](https://wordpress.org/support/plugin/canonical-attachments/)

## Donaci

Ĉu vi volas subteni la pluevoluigon de tiu ĉi kromprogramo?

 [ Donaci al tiu ĉi kromprogramo ](https://www.hivedigital.com/2017/01/19/canonical-attachments-in-wordpress/?utm_source=wordpress&utm_campaign=canonical-attachments&utm_medium=donate-link)