3Redirect sub domain to another host

Redirect sub domain to another host

I manage several hosting accounts all of which have a specific purpose. For example, I have an account for hosting my own personal sites, another for client sites and then a third host for development purposes. With my development server this is where I’ll develop various sites and applications which I can then demo to the client. However, to maintain a consistent brand whilst keeping the development stuff away from the live stuff means that I’ve had to redirect a sub domain from my live server to the development server. I do this for each new client I do work for.

So how exactly do you do this? Well, let’s say I wanted to redirect the sub-domain “something.michaelgarethmorgan.com” to another hosting account which is on a completely different server. I’d need to know the IP address of the alternate host as well as have cPanel access on both servers.

So, on the main server in cPanel go to “Simple DNS Zone Editor” which is a utility that lets you create A and CNAME records. For this task we’re going to create a new A record. In the name field simply type “something” – whatever you put here will be used as the sub-domain. In the address box type in the IP address of the alternate host, then click “Add A Record”.

Now, log into cPanel on the alternative server. Here, we’re going to simply add a new sub-domain, in this case it would be “something”. Once the sub-domain is created whenever I were to visit “something.michaelgarethmorgan.com” it would serve the files from the alternate server without you even knowing it.

This can be very useful if you’d like to keep your media and bulky files stored on a separate server away from the one handling your everyday web traffic. This can not only reduce server load but can also make it easier to maintain your files.

And that’s it. Redirecting a sub-domain to another host only takes a minute or two.

22SEO – The domain is vital

SEO – The domain is vital

Importance of domain nameOver the past few years and in particularly the last 18 months I’ve come to realize what I consider to be the most important factor for getting ranked high in the search engine results of todays search engines. It’s all about the domain name.

Okay, so maybe it’s not ALL about the domain name but the domain definitely plays a very big part. I’m saying this not based on scientific facts or even based on any particular tests or experiments but instead I based this on my own experience with SEO. Over the past 18 months or so I’ve launched several sites, some of which have achieved a page #1 ranking in Google whilst others have not. For each of these sites I’ve done the standard search engine optimization tasks including optimizing keywords, link building, article marketing and more. Looking over my sites I can see a trend that in general the sites whose domains are either an exact or very similar match to their primary keyword/phrase seem to be ranking much better compares to those sites whose domains are slightly less specific.

From this I’m led to believe that one of the most important things you can do if you intend to rank well in the search engines would be to make sure you choose the right domain name. I am by no means saying that choosing the perfect domain on its own will get you ranked higher. Instead I’m simply saying that a better, more specifically matched domain from what I can see has a big impact on how your site will rank (at least with Google).

21I’m not happy with Apple

I’m not happy with Apple

Apple affiliatesWhat’s the worst thing that could happen to an affiliate site whose revenue comes from selling cases for the iPhone? Well, it’s happened to me. Due to the signal issues with the iPhone 4 Apple have decided that they will now provide free bumper cases to those who have or are about to purchase an iPhone 4. On top of that they are also offering a full refund to all customers who have previously purchased a bumper case from Apple.

I’ve seen the effects of this with one of my affiliate sites right away and have watched sales figures plummet since the announcement was made. Sure, my site may not be affiliated with the official bumper case product but who’s going to buy an iPhone case if Apple are handing them out for free? There may be the occasional iPhone owner who wants something different than what Apple is offering and may go ahead and purchase their own but this has put myself and many other iPhone accessory affiliates at a disadvantage which will likely cost quite a bit in affiliate sales.

I guess it’s time to concentrate my SEO efforts on alternative products.

19Upload an image using Java + PHP

Upload an image using Java + PHP

Whilst working on a recent project I needed a way of transferring images (screenshots to be specific) from the client machine to a web server hosted in the cloud. My choice of platform was Java on the client machine and then PHP on the server side to recieve and process the upload.

So basically I needed to upload an image to a web server using Java and PHP. Reading and writing simple data to and from a web server with Java is pretty easy really but when it comes to transferring files things get that little bit tougher. This is because when uploading files the content type of the HTTP request changes from plain text to multipart making it trickier. You could either write a whole load of extra code to deal with this or you could simply send the data over as plain text and then just let PHP deal with it. Here’s how it’s done. Yay

19I’ve graduated

I’ve graduated

I’m actually a few days late posting this as it happened mid last week, but, I’ve now graduated from university with a upper second class honours degree in Software Engineering. One thing is for sure is that I’m glad to have it over and done with. It’s not that the work was particularly difficult it was just that I don’t particularly like writing 5,000 word reports :P

I suppose some sort of celebration is in order :)

5Themedy – Free WordPress theme

Themedy – Free WordPress theme

I’d like to share with you my latest free WordPress theme which is called Themedy. This free WordPress theme comes packed with plenty of cool features including four colour schemes, a customizable image scroller and much more. You can quickly and easily change things like the colour scheme, the scrolling images (and their link), footer text, navigation text and more right from the administration panel.

Free WordPress theme - Themedy

A demo is available here.
This WordPress is available for use for free and can be downloaded here.

28I have an iPad

I have an iPad

I’ve had my eye on an iPad for quite some time now and I finally gave in. After a little shopping around and a few days of hearing the words “out of stock” I finally found somewhere which had one. I ended up getting a 16gb wifi only iPad from PC World.

And, I absolutely love the thing! I’ve barely put it down since I got my hands on it yesterday.

24Comments are back

Comments are back

A little while back when I redesigned this site I, for whatever reason decided not to make use of the comments section meaning not only could no one post comments to any of my posts but also that existing comments made prior to the redesign simply dissapeared. I’ve now decided to bring comments back so now anybody can say what they think. So… get commenting!

24jQuery toggle fade in/out

jQuery toggle fade in/out

jQuery toggle fade in/outFor a recent interface design I had to apply a little jQuery to make some of the page interactions more intuitive (and nicer to use). One of the things needed was a quick and easy to way to toggle a particular elements display but in a way so that it faded in and out. The idea was simple – have a class which could be attached to a bunch of anchor tags which when clicked would fade in a div element. Then, upon clicking on that link (or any of the other links which also had the same class) the div element would fade out.

It’s actually quite easy really. Here’s the code for toggling an element on click with jQuery.

1
$('#hiddenbox').animate({opacity: 'toggle'}, 'fast');

To use it simply have an anchor tag like this…

1
<a href="" class="toggle-fade">Toggle box</a>

And then the jQuery code…

1
2
3
4
5
6
$(document).ready(function(){
	$('.toggle-fade').click(function(){
		$('#hiddenbox).animate({opacity: 'toggle'}, 'fast');
		return false;
	});
});

Perfect!

23CodeIgniter model database interaction

CodeIgniter model database interaction

Recently I’ve been doing quite a bit of work with the PHP MVC framework, CodeIgniter. First of all – it’s great! I’ve always been a fan of object oriented programming software approaches and the CodeIgniter handles this almost perfectly. As my CodeIgniter based projects start to grow, more and more database tables are introduced which is made a lot easier with the model part of the MVC design pattern.

When it comes to CodeIgniter though I’ve found that all of my table models all have the same 2 common functions. To me it makes sense to have this functionality built into the parent ‘Model’ class within CodeIgniter but since they’re not here they are for you to add them yourself.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function get($where = array(), $limit = 1000, $offset = 0)
{
	$rows = array();
 
	$this->db->select('*');
	$this->db->where($where); 
	$query = $this->db->get("tablename", $limit, $offset);
 
	// How many rows?
	if($query->num_rows() > 0)
	{
		// Loop through each row
		foreach($query->result() AS $row)
		{
			$rows[] = $row;
		}
	}
 
	return $rows;
}
 
function get_by_id($ID, $where = array())
{
	$where = array_merge(array('ID' => $ID), $where);
	$rows = $this->get($where, 1);
	return $rows[0];
}

So what exactly are these two functions? They’re a quick and simple way for retrieving information from a database table using the relevant model within your application. By simply calling either of these functions you can quickly retrieve whatever data required and then carry on without needing to worry about table names, etc. So, if for example for whatever reason you had to rename a table you’d only need to modify it in just the one place (in the model) as opposed to having to wade through all your code if you’ve typed it manually. Sure, the likelyhood of you changing a table name is quite slim but you never know.

Of course you may want to extend this to allow for updates, deletes and inserts which only takes a few minutes. Just thought I’d put this out there in case anyone’s interested.

Page 1 of 41234