A WordPress plugin that replies a 301 permanent redirect, if requested URI is different from entry’s (or archive’s) permalink. It is used to ensure that there is only one URL associated with each blog entry.
- Download: Permalink Redirect Plugin 2.0.5 (PHP, 16.8kb, 2011-04-17)
- Download: Permalink Redirect Plugin 2.0.5 (ZIP, 5.3kb, 2011-04-17)
- Subversion Repository: svn.fucoder.com/fucoder/permalink-redirect/
- Download the plugin file, and unzip the file.
- Upload “ylsy_permalink_redirect.php” to your WordPress’
- Activate the “Permalinks Redirect” plugin in your WordPress admin page.
I am not sure why the WordPress people insist that,
GET /2005/05/29/foo-bar HTTP/1.1
is exactly the same as
GET /2005/05/29/foo-bar/ HTTP/1.1
If you have not spotted the difference, one has a trailing forward slash ‘/’ in the URI and one does not. For one is requesting the content of object ‘foo-bar’ under directory ‘/2005/05/29/’, and another one is requesting the content of the index file under directory ‘/2005/05/29/foo-bar/’. Although many of us would usually ignore the trailing slash, and write out the URL without it, web servers usually will correct this behaviour by replying a 301 permanent redirect to an URL with the trailing slash, if ‘foo-bar’ is indeed a directory.
However, not so with the default mod_rewrite rules generated by WordPress. To save number of rules need to be generated, WordPress short-cuts the regular expression to allow optional trailing slashes at the end of the URL. This results that you can now point to the same entry/archive with or without the trailing slash – which goes against what a search engine would recommend. Here is an extract of Google’s recommendation to the webmasters, under “Quality Guidelines – Specific recommendations”:
Don’t create multiple pages, subdomains, or domains with substantially duplicate content.
Now if I search Google for certain keywords, I sometimes see two results came back from the same domain – same blog entry but one with a trailing slash in its URL, and one does not.
For example, mtsend. This is certainly not what I have desired. I used to modify all the mod_rewrite rules generated by WordPress, so that Apache will issue a 301 redirect if the trailing space is missing. However, it is tedious, and might not be compatible when WordPress upgrades. Moreover, your
.htaccess can become huge and getting unmaintainable.
Therefore, this simple WordPress plugin is written. It compares the request URI, and if it does not match the permalink, a redirect will be sent back instead. It works not only for individual blog and page entries, but also yearly, monthly, daily and category archives.
From version 0.5, Permalink Redirect plugin adds an extra page under WordPress Options menu. Here are the options that it handles:
Let permalink redirect plugin to redirect all
/feed/to a FeedBurner feed address.
This option is useful when you want to track your feed statistics via FeedBurner. You can continue to advertise your feed with the old address, but it sends a 302 Found and redirect to FeedBurner. Note that it does not always work as it is possible for WordPress to send back 304 Not Modified before this plugin has a chance to execute. (New in 0.6.0)
If checked, it will redirect all requests that are accessing pages not via the authentic hostname defined by WordPress Address in General Options page.
For example, if WordPress Address is
http://www.mydomain.com, and accessing
http://mydomain.com/2007/my-postwill be redirected to
Old permalink structure. If set, all access to old permalink structure will be redirected as well.
A new-line separated list of regular expression patterns that Permalink Redirect plugin will skip matching and redirecting.
Please contact me if you have any question regarding this plugin.
Frequently Asked Questions
- I have changed my permalink structure in WordPress. Can this plugin help me to redirect old links to the new?
Yes, but not in a trivial way. I have written a HOWTO on it. Give it a try.
As of Permalink Redirect 0.7.0, the perferred way is to set the “Old Permalink Structure” in the options page, and Permalink Redirect plugin will handle everything for you.
- 2.0.4 (2009-09-17)
- Fix author link trailing slash issue. (Thanks to Carlos for reporting it)
- Fix feed URL trailing slash issue.
- Fix tag URL issue. (Thanks to Matthew Gallant for reporting it)
- 2.0.1 (2008-11-05)
- Fix redirection loop issue with permalink structure that does not end with a slash in WordPress 2.5+
- 2.0 (2008-07-17)
- Rewrite of old permalink structure handling functions.
- 0.8.1 (2007-07-20)
- Fix 301 redirect issue with Lighttpd/Nginx + PHP FastCGI.
- 0.8.0 (2007-07-12)
- Add FeedBurner branding support (thanks to Mesoconcepts for sponsoring).
- Add static page redirect (thanks to Sergey Menshikov).
- Fix front page as static page issue in WordPress 2.2.
- 0.7.0 (2007-04-11)
- Add Old Permalink Structure redirect.
- Add Hostname redirect.
- Fix skip rules to check the entire REQUEST_URI.
- 0.6.3 (2007-03-06)
- Fix category feed URL issue reported in forum.
- 0.6.2 (2007-01-30)
- Fix WordPress 2.1 specific issues involving using a static page as front-page or posts page.
- 0.6.1 (2006-09-17)
- Fix FeedBurner URL presented in the option page. (Thanks to Denis de Bernardy)
- Only redirect to FeedBurner from main feeds, not archive or comment feeds.
- Fix issues with invalid URI that causes
- 0.6.0 (2006-06-20)
- Add FeedBurner feed redirect.
- Do not perform a redirect if in archive page without any post. Resolved Vincent’s issue
- 0.5.3 (2006-06-04)
- 0.5.2 (2006-04-23)
- Add “permalink_redirect_skip” filter to allow other plugins to manipulate the redirect skipping rule. Patch provided by Denis de Bernardy.
- 0.5.1 (2006-04-22)
- Fix up typo for “Permanent”. Reported by Ara.
- 0.5 (2006-02-22)
- 0.4.2 (2005-12-20)
- Make it working under WordPress 2.0.
- 0.4.1 (2005-10-24)
- Fix up a bug when blogsite is in a directory.
- 0.4 (2005-10-23)
- Handle multi-page entries and paged archives. Exact match is forced.
- 0.3 (2005-06-05)
- Properly handle cases when 404 Not Found is encoutnered.
- 0.2 (2005-06-02)
- Add support for
?m=yyyymmddquery string. Add support for pages and author archives.
- Add support for
- 0.1 (2005-05-29)