Zend Framework Logo.I got a simple way to do canonical urls for a web application that uses Zend Framework (one of the best tools to making building a website fast and easy) for a smaller website. This might not be the best way to do it, but it sure works.

You want to do canonical urls so that search engines like Google will know exactly what url you want to be indexed.

For example, do you want your website to use http://www.example.com/index.html, or do you want http://example.com, or http://example.com/index.html, etc? This way if someone links to you in one way, it will always revert back to the url you specified in your header tag.

So, in your Zend Framework application you will want to go to your application folder depending on how you have your file structure set up. Then your layout folder, then your scripts folder, then open up to edit your layout.phtml file.

Now within the <head> tag, put this code and replace with how many pages you have on your site and how you want the urls to look like.

<link rel="canonical" href="<?php $request = Zend_Controller_Front::getInstance()-> getRequest()->getActionName(); if ($request == 'index') echo 'http://example.com'; elseif ($request == 'contact') echo 'http://example.com/contact'; elseif ($request == 'about') echo 'http://example.com/about'; elseif ($request == 'services') echo 'http://example.com/services'; else echo ''; ?>" />

So the $request variable simply gets the instance of the request from your controller, so there is nothing else needed to do to make this code work in your Zend Framework project. Hope this info is useful to you.

Tags: , , , , , , , , , ,

Greg London on April 3rd, 2012

NETDomainHosting.com Logo. I wanted to write this article to give a thumbs up to my hosting Company, NET Domain Hosting. I’ve been using NET Domain Hosting since 2005 and if I ever have a problem or concern with one of my websites, they always make sure I’m taken care of. I can call them knowing I have 24/7 phone support if I need help with anything and I always great customer service.

So let’s quickly list some of the services this hosting Company provides:

  • Buy domain names, .com, .net, .biz, etc.. Whatever extension you need!
  • Provides hosting, from shared to dedicated.
  • Web design software, if you need it…..
  • 1 click install of WordPress and other great open source forums, etc….
  • SSL security certificates to protect your business transactions.
  • Multiple email addresses with your domain names.
  • Marketing tools like autoresponders and Search Engine visibility

NetDomainHosting.com offers more services than this, but I’m already getting tired of talking about it. I mainly just wanted to quickly give my 2 cents on why you might want to consider switching to them if you already have a hosting Company that ain’t that great, or if you’re just starting out and need to get a website up and running.

Tags: , , , , , , , , , , , , ,