Flash and SEO has been quite a problem and the main argument for the people in the business who is against Flash. I’ve planned to do something about this for a long time and finally I found a project that was suitable to try this. First I will say that many people think that making a website completely in Flash is craziness, and very often I do agree. However sometimes the client wants a “flashy” site with lots of animations and stuff and how am I to deny them that?
Since the introduction of SWFObject it’s been quite easy to provide the user with html content for those who does not have flash installed, and this is what I’ve done. Since I use amfphp a lot and also for my little CMS for flash, all the content except from the images are stored in a mySQL database. This makes it easy to extract all the content and echo it out in the flashcontent div tag.
I did this for a project called moelo.no and after a while Google index the whole site. To make it even more search friendly I used Apache Rewrite Engine to replace the query string URL with more search friendly URLs. I was surprised how easy easy it was to write the rewrite rule. Here is the all the lines I had to write to make it work:
RewriteRule ^kategori/([0-9]+)/underkategori/([0-9]+)/prosjekt/ ([0-9]+)(.*)\.html$ index.php?KategoriID=$1&UnderkategoriID=$2&ProsjektID=$3
RewriteRule ^kategori/([0-9]+)/underkategori/([0-9]+)(.*)\.html$ index.php?KategoriID=$1&UnderkategoriID=$2
RewriteRule ^kategori/([0-9]+)(.*)\.html$ index.php?KategoriID=$1
Now basically what this does is rewrite a url that looks like this:
Then I add a suffix that takes the title of the article as filename and adds a .html extension to the end to to the URL to make it even more search friendly. The rewrite engine rules just ignores this. Now the URL looks like this:
The next trick was to actually show the right content in the flash version as well when a user clicked a link in Google. I did this very easy by passing the arguments to SWFObject and this way I could load them as variables in flash:
var so = new SWFObject("http://www.moelo.no/index.swf", "index", "1000", "600", "8", "#ffffff");
Finally I added a rule in the robot.txt file that blocks the SWF-file from all robots.
It works like a charm!
The next job is to rewrite my hole flash based CMS into OOP because the hole shit is written in procedural code. This happened because it started as a minor project a long time ago and it has escalated for each project, and this makes it a pain in the ass to update and maintain.