Title: Permalink Validator
Author: snakefoot
Published: <strong>Июн 16, 2007</strong>
Last modified: Август 17, 2009

---

Search plugins

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://s.w.org/plugins/geopattern-icon/permalink-validator.svg)

# Permalink Validator

 By [snakefoot](https://profiles.wordpress.org/snakefoot/)

[Download](https://downloads.wordpress.org/plugin/permalink-validator.0.8.zip)

 * [Details](https://tg.wordpress.org/plugins/permalink-validator/#description)
 * [Reviews](https://tg.wordpress.org/plugins/permalink-validator/#reviews)
 *  [Installation](https://tg.wordpress.org/plugins/permalink-validator/#installation)
 * [Development](https://tg.wordpress.org/plugins/permalink-validator/#developers)

 [Support](https://wordpress.org/support/plugin/permalink-validator/)

## Description

WordPress 2.3 now includes validation of the permalink URL when using Apache web
server,
 but if using IIS then this plugin is still relevant.

Permalink Validator helps Search Engine Optimization (SEO) as it prevents duplicate

contents on your WordPress blog:

 * Adds trailing back-slash if missing (Can also be done with [htaccess](http://www.alistercameron.com/2007/01/12/two-wordpress-plugins-you-dont-need-and-shouldnt-use/)
   or [isapi_rewrite](http://cephas.net/blog/2005/07/11/trailing-slashes-iis-and-f5-big-ip/)).
 * Adds or removes www prefix according to your permalink structure (Can also be
   done with [htaccess](http://andybeard.eu/2007/04/the-ultimate-wordpress-htaccess-file.html)
   or isapi_rewrite).
 * Forces a correct 404 page instead of showing an empty search result when using
   an invalid URL
 * Works only on post, pages and categories. Archives based on date (Daily, Monthly,
   Yearly) and search-result-pages should use noindex. Feed and trackback pages 
   should be added to the robots.txt.
 * Fixes pagination for WP on IIS.
 * Fixes trailing slash for pages and categories on WP 2.2 when not having trailing
   slash in post permalink structure.

WordPress it very forgiving when supplying an URL that doesn’t match the
 actual
permalink to a post or a page. This is caused by WordPress using some very greedy
wp_rewrite_rules, which accepts almost any URL as valid.

This means that multiple URLs could be used to reach the page, which search engines

sees a duplicate content and leads to penalty.

For example it will accept the following permalink URL as valid:

> http://example.com/post/hello-world/2

Even though the official URL is this:

> http://example.com/post/hello-world/

Permalink Validator makes a hook to template_redirect, and then adds some
 extra
validation of the URL supplied before actually calling the theme-templates.

### Version History

Version 0.8

 * Fixed PHP Warning: strpos() [function.strpos]: Empty delimiter
 * Converted the PHP file from UTF8 to ANSI (Removed special BOM character in file
   beginning)

Version 0.7

 * Permalink Validator will not perform redirect of POST server request

Version 0.6

 * Fixed a redirection bug introduced in 0.5 when the front page is a page of posts

Version 0.5

 * WordPress 2.3 includes permalink validation (canonical urls) when using Apache,
   so this plugin should now only be used with IIS
 * Added support for HTTPS urls
 * Added support for special IIS installations where PATH_INFO and SCRIPT_NAME is
   the same
 * Added small hack to exclude pages from validation (One is required to edit the
   source to use it)
 * Added detection of the plugin [Jerome’s Keywords](http://vapourtrails.ca/wp-keywords)

Version 0.4

 * Better guessing of a proper REQUEST_URI
 * Finds the proper REQUEST_URI when using isapi_rewrite
 * Finds the proper REQUEST_URI when using IIS Mod-Rewrite
 * Improved validation as it nows expects a proper REQUEST_URI (Guess Apache is 
   now supported)

Version 0.3

 * Fixes trailing slash for pages and categories in WP 2.2 when using a post permalink
   structure without ending slash.

Version 0.2

 * Added support for static front page.
 * Added detection of integrated [BBPress](https://bbpress.org/).
 * Checks that WordPress has been started before adding hooks

Version 0.1

 * Fixes REQUEST_URI for WP on IIS, which also fixes pagination.
 * Handles permalink structure with or without index.php.
 * Handles default permalink structure using only post-id.

### Testing Procedures

For each of the different permalink structures:

 * Default permalink structure (Using query string)
 * Permalink structure with index.php
 * Permalink structure without index.php (Using ISAPI_rewrite)
 * Permalink structure ending with .html
 * All the above in a sub-directory

Tries the following pages:

 * Front page and paged
 * Static page
 * Post page
 * Category page and paged
 * Front page as static page (WP 2.2+)
 * Front page as post page (WP 2.2+)

### Contributors

 * [Scott Yang](http://fucoder.com/code/permalink-redirect/) for giving me the idea
   and the example of to how make this plugin.
 * [Gabe Anderson](http://www.articulate.com/blog/) for giving me the initiative
   to release this plugin.

## Installation

 1. Upload `permalink-validator.php` to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

## FAQ

  Why should I use this instead of htaccess or isapi_rewrite ?

If having the ability to use htaccess or isapi_rewrite, then one should continue

to use these to add missing trailing back-slash or www prefix. They are a lot faster
at redirecting than Permalink Validator, as they are activated without starting 
the PHP script engine when the URL has incorrect format.

Permalink Validator extends the validation so besides checking the format,
 then
it also checks that the url is referring to something valid. The validation of the
url doesn’t generate any extra overhead in database queries (unless the url requires
redirection).

  Why does it redirect continously when activating the plugin ?

The plugin makes a redirect when the url used to reach the page doesn’t match the
expected permalink url.
 Some times this leads to an endless loop, which Firefox
shows as:

> The page isn’t redirecting properly
>  Firefox has detected that the server is redirecting the request for this address
> in a way that will never complete. 
>  * This problem can sometimes be caused by
> disabling or refusing to accept cookies.

This can be caused by a conflict in the htaccess / isapi_rewrite redirection rules
and the given permalink structure:

 * If enforcing trailing back-slash and the permalink structure doesn’t include 
   it.

If this is not the case then you are very welcome to post a topic with your problem
as feedback to this plugin.
 Please include your permalink-structure and WordPress
version in your description of the problem.

  How to exclude pages from being permalink validated ?

The Permalink Validator will pretty much validate any URL you throw at it,
 but 
sometimes there are URL’s that should not be validated.

Edit the plugin-code and replace this line:

> $excludes = array();

With an array of the URL’s to ignore:

> $excludes = array(«/forum»);

Plugins that requires an URL excluded:

 * [Subscribe to Comments](https://wordpress.org/extend/plugins/subscribe-to-comments/)–
   Exclude «/?wp-subscription-manager»
 * [wp-forum](https://wordpress.org/extend/plugins/wp-forum/) – Exclude «/forum»

  How to block search engines from spidering WordPress feed and trackback ?

Add the following lines to your [robots.txt](http://www.robotstxt.org/):

> Disallow: */feed 
>  Disallow: */atom  Disallow: */rss2  Disallow: */rss  Disallow:*/
> trackback  Disallow: /*/feed  Disallow: /*/atom  Disallow: /*/rss2  Disallow: /*/
> rss  Disallow: /*/trackback

  How to make proper permalink URL’s in IIS ?

WordPress supports by default Apache htaccess and its mod_rewrite rules.
 When using
WordPress on IIS then these will not work and one is limited to this type of permalink:

> http://example.com/index.php/post/hello-world/

To remove the index.php, then one can either use the [custom 404 redirects](http://www.keyboardface.com/IIS-Permalinks/)

or [isapi_rewrite](http://www.basilv.com/psd/blog/2006/running-wordpress-20-under-iis).

If using isapi_rewrite and changing from using index.php to not using index.php,

then one can use the following httpd.ini (Assumes WordPress is installed in the 
root):

> [ISAPI_Rewrite]
>  # Rules to ensure that normal content gets through  RewriteRule/
> software-files/(.*) /software-files/$1 [L]  RewriteRule /images/(.*) /images/$
> 1 [L]  RewriteRule /favicon.ico /favicon.ico [L]  RewriteRule /robots.txt /robots.
> txt [L]
> # For file-based wordpress content (i.e. theme), admin, etc. 
>  RewriteRule /wp-(.*)/
> wp-$1 [L]
> # Rule to perform 301 redirect to ensure trailing back-slash on post and pages
> 
> RewriteCond Host: (.*)  RewriteRule ([^.?]+[^.?/]) http://$1$2/ [I,R]
> # Rule to perform 301 redirect (Remove index.php if specified) 
>  RewriteRule /
> index.php/(.*) /$1 [I,RP]
> # For normal wordpress content, via index.php 
>  RewriteRule ^/$ /index.php [L]
> RewriteRule /(.*) /index.php/$1 [L]

  Why doesn’t it redirect on IIS when the URL is wrong ?

Permalink Validator cannot see the difference between this url:

> http://example.com/

And this url on IIS:

> http://example.com/index.php

It can also not see the difference between this url:

> http://example.com/

And this url on IIS:

> http://example.com/////

This is because REQUEST_URI is not supported properly on IIS, and this
 plugin can
only simulate REQUEST_URI to a certain limit. Therefore it is impossible to know
whether index.php or extra slashes was specified or not. The solution is to use 
a rewrite engine like [ISAPI_rewrite](http://www.isapirewrite.com/) or [IIS mod-rewrite](http://www.micronovae.com/)
as they can provide a proper REQUEST_URI.

  Why does a non existing page give HTTP error 200 on IIS ?

Microsoft IIS fails to reply with error code 404 in the HTTP header,
 when trying
to access an non existing WordPress page. This usually happens when using a custom
404 page on IIS.

It seems that when using PHP on IIS, then it is not possible to reply
 with a proper
HTTP header. Apparently the only way to return a proper 404 on IIS is to use ASP.

  Will Google tracking code work with this plugin ?

Google tracking code adds a question-mark (?) option to the URL, which the
 Permalink
Validator will strip because it is not part of the permalink URL.

Instead of using a question-mark (?), then one could use a hash (#) value,
 and 
then modify the Google tracking code to extract the hash value instead of the question-
mark value.

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Permalink Validator” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ snakefoot ](https://profiles.wordpress.org/snakefoot/)

[Translate “Permalink Validator” into your language.](https://translate.wordpress.org/projects/wp-plugins/permalink-validator)

### Interested in development?

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

## Meta

 *  Version **0.7**
 *  Last updated ** 17 сол ago**
 *  Active installations **10+**
 *  WordPress version ** 2.0.0 or higher **
 *  Tested up to **2.6**
 *  Language
 * [English (US)](https://wordpress.org/plugins/permalink-validator/)
 * Tags
 * [301](https://tg.wordpress.org/plugins/tags/301/)[404](https://tg.wordpress.org/plugins/tags/404/)
   [iis](https://tg.wordpress.org/plugins/tags/iis/)[permalink](https://tg.wordpress.org/plugins/tags/permalink/)
   [redirect](https://tg.wordpress.org/plugins/tags/redirect/)
 *  [Advanced View](https://tg.wordpress.org/plugins/permalink-validator/advanced/)

## Ratings

No reviews have been submitted yet.

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

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

## Contributors

 *   [ snakefoot ](https://profiles.wordpress.org/snakefoot/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/permalink-validator/)