Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Automatical Redirect and Canonical

Does WP set a 301 and canonical-tag automatically, based on URL-setting?

         

deeper

5:39 pm on Aug 28, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi,
since 2.9 WP sets a canonical metatag automatically.

The article at [premium.wpmudev.org...] says two things I'd like to be confirmed:

-WP sets a 301 redirect. Hm, obviously the author wants to say, that WP does both, 301 and canonical-tag and both automatically. But my htaccess has no 301 which is created by WP!?

-301 and/or canonical-tag is based on the URL which is given by the admin at the "general settings" of WP. The codex of WP doesn't confirm this, but it would make sense.

not2easy

7:06 pm on Aug 28, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Canonical metatags have to do with multiple pages with similar content, the canonical issue discussed in that article is about www vs. non-www identical content. The www canonical issue is handled automatically in WP based on the settings in place in the WP settings and is adjustable by an admin. It should be set to the preferred URL at the time of installation and not changed. This does not automatically insert any canonical metatags, it serves to redirect requests for www (or non-www) requests to your preferred setting.

The plain WP section in your htaccess file should look something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

And it translates the www settings that were made to the proper canonical rewrite, though it doesn't have the appearance of a non-WP 301.

If you need canonical metatags for individual pages, there are plugins to help with that.

deeper

8:13 pm on Aug 28, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



If the URL-setting in WP does not cause canonical metatags automatically, why do I have them on each page? Theme-provider says it's WP, not the theme creating them. Strange...

"...is adjustable by an admin". You mean things like changing the URL from www. blabla.com to blabla.com?

"...though it doesn't have the appearance of a non-WP 301". The author is talking explicitly about "301". Do I understand you right, that this is misleading because it has only the (almost) same effect, but WP does not create a real 301 in the htaccess, i.e. naming it 301 like ....[R=301,L]..?

not2easy

9:00 pm on Aug 28, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You should not want to have canonical metatags on every page of most sites. In WP, several different versions of your content are created. You might want to have a canonical metatag for www.example.com/2014/news-about-widgets and www.example.com/widgets/news-about-widgets and www.example.com/news/news-about-widgets to point to your preferred version, but then you don't want that metatag on your preferred version. Or you can noindex the copies.

"...is adjustable by an admin". You mean things like changing the URL from www. blabla.com to blabla.com?
yes.

"...though it doesn't have the appearance of a non-WP 301". The author is talking explicitly about "301". Do I understand you right, that this is misleading because it has only the (almost) same effect, but WP does not create a real 301 in the htaccess, i.e. naming it 301 like ....[R=301,L]..?
no. The code in htaccess produces a real 301, but it does the work from within the WP CMS so you don't need to manually add in a rewrite for every "directory", so the appearance of the code that you see does not look the same as if you were using only htaccess for the 301. The URLs to be rewritten do not exist in a static format, the sql database for WP contains the URL taxonomy settings that were set up in the Settings for WP. WP processes that information for requests and takes care of the 301 when required. But, yes, it is a real 301. You can use different tools to check your headers and verify if you have doubts.

deeper

1:54 am on Aug 29, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



I use WP as CMS for some corporate sites with static pages. There is no danger for duplicate content because of archives ect. May be later an onsite blog will follow. Then I will prefer to noindex archives ect.

But at the moment I find a canonical metatag in the head of the pages, with an URL pointing to itsself and I ask myself surprised "who does this" and "why"?

Regarding "real 301": In the past (without WP/CMS) I supplemented manually this standard code for www-redirect in the htaccess:
RewriteCond %{HTTP_HOST} !^www\.domain\.de$
RewriteRule ^(.*)$ [domain.de...] [L,R=301]

Using WP this is not necessary any more, though the plain WP section in my htaccess does not show any visible "301" for my eyes?

not2easy

2:18 am on Aug 29, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



That is right, assuming that your WP is installed in the root directory and there are not other folders and files outside of WP on the same domain. If your WP install is not in the domain root and there are other files and folders outside of WP you do need to have the www 301 in htaccess, separate and before the # BEGIN WordPress section in the same htaccess file. WP only handles the 301 for WP URLs.

As for the source of the metatags I would look first at plugins you are using.

deeper

3:35 pm on Aug 29, 2014 (gmt 0)

10+ Year Member Top Contributors Of The Month



It's a test installation. The only Plugin I use is Backupbuddy.

I found two sources claiming WP creates the canonical automatically:
[wordpress.stackexchange.com...]
[wplifeguard.com...]