Home arrow PHP arrow Page 2 - Managing Secure Protocol in Apache-Based Websites using PHP

First Potential Problem: Duplicate Content! - PHP

When trying to maintain a secure protocol on an Apache-based website, you can expect to deal with certain issues, especially if you're also trying to rank well in the search engines. This article provides you with some solutions for two of the more difficult problems: duplicate content and 301 redirects.

  1. Managing Secure Protocol in Apache-Based Websites using PHP
  2. First Potential Problem: Duplicate Content!
  3. Second Duplicate Content Solution
  4. Second Potential Problem: 301 Redirection from non-secure to secure protocol
By: Codex-M
Rating: starstarstarstarstar / 5
May 28, 2009

print this article



If your security certificate is now issued or running and the configuration of the https was done right on your server, the first thing you need to avoid is duplicate content in the https protocol. A lot of websites make this mistake, and Google ends up indexing both protocols (http and https). This is considered a serious duplicate content issue in Google.

If both the http and https versions of your web site can be indexed, you will see serious ranking issues stemming from the duplicate content. These issues arise because Google splits up the link authority between the http and https protocol instead of concentrating it in the http protocol, which is preferable to rank in Google. This weakening of the internal link structure affects the site's search engine optimization efforts.

There are basically two ways to correct this. The first method seems to be the most effective in start up websites (if Google has not yet indexed the https version). The second method will be applicable if Google already indexes the https version aside from the canonical http version, and the https version has some Google Page rank.

FIRST SOLUTION: In all https (secure) pages, place a Meta no index tag.

Wow, what is Meta no index tag anyway? The most recommended format is:


According to Google, when they see this tag on the page, Googlebot will still crawl the page as well as the links, but will not index the site to place it in the search results. This should avoid issues with duplicate content.

So what is the PHP script for the firstsolution?


if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')









This script will check to see if the protocol running is https. If it is a secure protocol, it will return the meta noindex tag; otherwise, the page will be indexable by Googlebot.

To use this script, you must insert it script somewhere in the <head> </head> section of your website template (one is that used by all pages, like header.php in WordPress). To find out if this is working according to plan, open any URL in your website which is not https. Try to view the source code of that page. You should see this:


Otherwise, if it is a secure protocol, it should have this instead:


>>> More PHP Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: