For Sites: All Sites  * Wordpress   For Browsers: All Browsers  * Firefox  * IE  * Chrome

» Home » Troubleshooter » PHP code to detect the default WordPress permalink structure

PHP code to detect the default WordPress permalink structure

If you changed the permalink structure of your WordPress blog from the default one (?p=n) to the so called “pretty permalinks”, perhaps you’d like to remove from the database of search engines all those addresses that followed the default permalink structure, in order to avoid duplicate content ‘punishments’.

A way to achieve this would be to detect if a page was opened from an address that follows the old permalinks structure and then write the appropriate “noindex” Robots meta tag.

You can detect pages of the default permalink structure because they contain queries, using a question mark in their address.

The following code will detect if an address includes a query and then it will write the proper meta tags to the header.

<?php if($_SERVER['QUERY_STRING'] != '') {
echo "<META NAME=\"ROBOTS\" CONTENT=\"NOINDEX, FOLLOW\" />";
}
?>

If you have some other advice for a successful move to a new permalink structure, leave a note below.


Select Windows Freeware   Select Pure Windows Freeware


Related:



Don't miss:   Software Search Plugin   Google Gadget   Amazon Gadget



You are welcome to leave a comment here

This web site is for freeware only; feel yourself free to review an application, recommend it, ask for support - but please note: your post will be deleted if you try to promote a program that is not absolutely free. --

What is 5 + 4 ?
Please leave these two fields as-is:
«

 
»