Making mod_rewrite work for Apache server on Windows XP

Last year I set up an Apache 2.2 server on my computer to do some developement work using EzPublish in multiple virtual host environment. One day, I happened to raise a question to Steven on how to get it configured so that mod_rewrite works on my server and I could debug my script locally instead of always having to test it on some remote server. I got the response from him that it does not work in Windows environment. Due to the fact that this particular feature was not critical to the whole operation, I left it as that.

Two days ago out of curiosity, I downloaded this new PHP social networking software called ElGG . Apparently it uses mod_rewrite extensively and provides no other alternative methods to access its function. I was thus forced into a corner. Hence I did what I did. I went to google.com and started researching. Interestingly, I read that some actually got mod_rewrite working on Apache server running on Windows XP.

I spent the next two days researching on the Apache architecture. The result I got was this assuming you already have multiple virtual host setup:

  1. uncomment LoadModule rewrite_module modules/mod_rewrite.so in your httpd.conf file
  2. add the following lines to your vhost.conf files

    <Directory “…”>
    #Tells your Apache webserver to detect for the .htaccess file in your directory
    AllowOverride All
    </Directory>

  3. The below was copied lock stock and barrel from Joomla. Copy and paste it into a .htaccess file on your webserver and place it at the root location

    ##
    # @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
    # @package Joomla
    # @copyright Copyright (C) 2005 – 2008 Open Source Matters. All rights reserved.
    # @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
    # Joomla! is Free Software
    ##

    #####################################################
    #  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
    #
    # The line just below this section: ‘Options +FollowSymLinks’ may cause problems
    # with some server configurations.  It is required for use of mod_rewrite, but may already
    # be set by your server administrator in a way that dissallows changing it in
    # your .htaccess file.  If using it causes your server to error out, comment it out (add # to
    # beginning of line), reload your site in your browser and test your sef url’s.  If they work,
    # it has been set by your server administrator and you do not need it set here.
    #
    #####################################################

    ##  Can be commented out if causes errors, see notes above.
    Options +FollowSymLinks

    #
    #  mod_rewrite in use

    RewriteEngine On

    ########## Begin – Rewrite rules to block out some common exploits
    ## If you experience problems on your site block out the operations listed below
    ## This attempts to block the most common type of exploit `attempts` to Joomla!
    #
    # Block out any script trying to set a mosConfig value through the URL
    RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
    # Block out any script trying to base64_encode crap to send via URL
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
    # Block out any script that includes a <script> tag in URL
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    # Block out any script trying to set a PHP GLOBALS variable via URL
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    # Block out any script trying to modify a _REQUEST variable via URL
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    # Send all blocked request to homepage with 403 Forbidden error!
    RewriteRule ^(.*)$ index.php [F,L]
    #
    ########## End – Rewrite rules to block out some common exploits

    #  Uncomment following line if your webserver’s URL
    #  is not directly related to physical file paths.
    #  Update Your Joomla! Directory (just / for root)

    # RewriteBase /

    ########## Begin – Joomla! core SEF Section
    #
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/index.php
    RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
    RewriteRule (.*) index.php
    RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    #
    ########## End – Joomla! core SEF Section

If you are still having problems after all these steps contact me. I will help set it up for your nicely. 🙂

GMap2 is not defined on ThingsToDoSingapore.com

Apparently it seems the Google Map API isnt all that stable after all. On and off while loggin into my site ThingsToDoSingapore.com I encounter this problem of  GMap2 not defined.

GMap2 is apparently the core object class that one instatiates a map object from. I have been researching over the internet to find a work around this problem but it seems this is a very common problem that one faces when using the Google Map API.

This is very painful indeed as it is costing me traffic volumn. Ouch!

Improving the performance of Ajax on ThingsToDoSingapore.com

Recently I started working on Things To Do Singapore again.

Apparently the javascript libraries were getting quite thick and this was affecting the loading of the interface.

There is the use of the following :

  1. Xajax Library
  2. Jquery Library
  3. Google friends Connect Api
  4. Facebook Connect Api
  5. SWFUpload Library

After much observation I realised the SWFUpload Library sometimes takes too long to load and fails as well causing the whole interface to fail loading at time seriously affecting usability of the site. Perhaps this might be to cause of the high bounce rate I observer from my Google Analytics of 80%.

I spent this morning thinking how to go about solving this problem and this was the method I came to

Javascript library should be classify into two groups as critical and non-critical to user experience.

The Xajax Library, jQuery library are considered critical to user experience

The Google Friends Connect library as well as the Facebook Connect library are not often employed. though these two library are too tightly integrated with the core achitecture. Perhaps it was a bad design choice.

SWFUpload is not often used by other users and hence rarely employed.

Having done the proper classification, I next work  on loading the SWFUpload asynchronously after the other library and interface has loaded. This in face drastically reduced improved useer experience. It reduced user waiting time as well as at the same time reduced the error rate of the loading interface.

This was how I did it.

jQuery(document).ready(function() {

loadScript(“http://thingstodosingapore.com/swfupload/swfupload.js”);
loadScript(“http://thingstodosingapore.com/swfupload/swfupload.queue.js”);
loadScript(“http://thingstodosingapore.com/swfupload/fileprogress.js”);
loadScript(“http://thingstodosingapore.com/swfupload/handlers.js”);
//alert(“swf loaded”);
});

function loadScript(sScriptSrc) {
var oHead = document.getElementById(‘head’);
var oScript = document.createElement(‘script’);
oScript.type = ‘text/javascript’;
oScript.src = sScriptSrc;
oHead.appendChild(oScript);
}

PHP set to further penetrate Enterprise solutions arena

What is Enterprise Application?
Enterprise Applications are software which provides business logic support functionality for an enterprise, typically in commercial organizations, which aims to improve the enterprise’s productivity and efficiency.

Characteristics of enterprise software:
Characteristics of enterprise software are performance, scalability, and robustness. Enterprise software typically has interfaces to other enterprise software.

Services provided by enterprise software are typically business-oriented tools such as online shopping and online payment processing, interactive product catalogue, automated billing systems, security, content management, CRM, ERP, Business Intelligence, HR Management, Manufacturing, EAI etc.

What is Scalability?
There are a number of different aspects of scalability. It always starts with performance, code maintainability, fault tolerance, and the availability of programming staff.

Why people has negative impression that PHP is only for small scale web-sites?
PHP is a language for the rapid development of dynamic Websites. It also has many features that are friendly to beginning programmers, such as the fact that it doesn’t require variable declarations. However, many of these features can lead a programmer inadvertently to allow security holes to creep into a Web application. The popular security mailing lists teem with notes of flaws identified in PHP applications, but PHP can be as secure as any other language once you understand the basic types of flaws PHP applications tend to exhibit.

PHP is an open source programming language that is widely popular on the web. However because PHP so popular in shared hosting environments, many people have an impression that PHP is only for small scale web-sites. This is patently untrue, and PHP is in use in many large scale web sites such as Yahoo, wikipedia and Lufthansa Online Ticketing for the creation of large web applications such as IMP.

Enterprises want to have specific assurances about a web technology they use in the following areas:

  • performance and fast development
  • reliability and security
  • extensibility – able to use industry standards to communicate with other software systems.
  • scalability – able to add additional servers as the load increases.
  • load balancing – ability to distribute the load so no single server is overloaded
  • high availability – ability to survive failure of server components transparently.

Conclusion:
To achieve high performance and scalability – it not only depend on language, it also depend on the developers.

Cited from Why not PHP for enterprise applications?

Problems integrating SWFupload with Joomla

I am currently working on integrating the SWFUpload library with Joomla 1.5. All seems to be working well except till the portion whereby the file is uploaded.

I get the response by the system to do a login and this response is returned to me via uploadSuccess(file, serverData) method in the SWFupload handlers.js file. The session is not maintained apparently when I do the post.

I am currently referencing http://docs.joomla.org/Creating_a_file_uploader_in_your_component for possible resolutions to this bug.

Now I am heading off to work as the Dancing Christmas tree. Hopefully I would solve it when I get back in the evening.

Extending Joomla to use Jquery

Recently there seems to be a lot of libraries that are being created using Jquery.

Joomla has been traditionally used with the  mootools library. Instead of using this library, I have opted to instead use the Jquery library.

I created a component for myself and  loaded the jQuery library into one of the sub folders of this Joomla component. I further instructed Joomla to load the javascript file.

Keeping my fingers crossed I wrote this syntex in the template file

<script>

jQuery(document).ready(function(){alert(‘hello world’)});

</script>

And Eureka!! It worked. Now I will go on further extending Joomla to create a very user friendly component for my clients which have been facing lots of problems with the counter-intuitive Joomla Administration interface.

Updating facebook fan page externally without the use of the Facebook API

Recently I managed to find time and hence decided once again to start work on my Things to Do Singapore!

One of the new features I had in mind of implementing was this auto updating of new sites to the Things to Do Singapore facebook fan page. The other thing I had in mind to do was to decrease the loading time experience for the site. The third thing I attempted to do was to improve the usability of the site. The second and third issue I believe is a constant task to work upon.

So back to the first feature. I researched for a long time on the facebook api site on how to update the facebook fan page automatically. Apparently apart from using the Open Streams API there was no other way around it. I further read that this was a tedious and complicated process. Hence I thought rather than have waste too much effort in the process of recreating the wheel, I researched for readily available solution.

This was when i chanced upon this page that talks in details on how to do auto import entries from a blog to a facebook fan page. Thus I did. I am glad he wrote what he wrote. There are so many features on facebook that sometimes i don’t even know if one exist when it actually does.

Google wave, the stanford model works, Serendipity

Seems like Google is coming up with a new web 2.0 platform again, this time specifically targeted at communications online.

It works pretty much like the winword document in the gmail except that this time you could also rewind time and see what was actually being written or edited at specific time intervals.

A video goes on to show that this algorithm has been originally been an area of academic research for the past 10 years before finally being commercialized in the form of Google Wave recently.

Seems like the Stanford model is working very nicely over in the States. What started as research in academies upon maturity gets rolled out commercially as spin offs.

The advantage that Google has is that fact that the whole company started out via this model as well. They are experienced in this.

In Singapore we do have something like this, but it seems owing to the general risk aversive culture of the place, this model is not taking off as well. Hey look, even my dad and mom has been nagging at me to get a stable job instead of constantly going through this process of trail and error that is inherent in technological ventures.

But hey no way am I going to call it quits that easily. I am still surviving so far am I not?

The other thing also is the lack of funding for start ups. Ironically, while lots of funds have been put in place to support start ups, fund managers are not really willing to seed start ups unless they are really confidant that their business model will be commercially viable.

Who’s to be sure anyway? Half of the really cool technologies around that were thought to have the potential to make a big bang when they hit the market never really did when they finally did arrive. Others that were thought to be flops magically succeeded at becoming dominant features on the internet without much explanation.

It is like choosing to play safe in an arena where the way to success contradicts the idea of playing safe. Hence most of these public funds get squandered off by companies who are good with paperwork to do stuff that is not aligned with the main objectives for the existence of these funds. The model is just not working.

Face it, success usually requires a certain amount of serendipity and the thing is such a thing is usually hard to predict. Mostly we are in the hands of God. It is like a leap of faith.

Kudos to that.

Every one has something to say – use a blog!

Recently I met a religio while on the bus on my way home. She took my contact number and started sending me lots of religious messages. Being a free thinker, most of these messages just came into my phone and went into the trash folder. It was just too long to read over an SMS. and I hate longs SMS s over the phone.

Then it occurred to me, I thought hey all these efforts by her should not be going to waste. so what happens immediately after that was that I set up a blog for her at adonis.name1price.com for her to send her message out to the world.

Now, my phone avoids getting overloaded with mesages not related to my essential day to day operations and at the same time she gains access to the whole world’s audience. And the whole world’s audiences may finally get themselves some salvation if indeed they are looking for some.

Who knows she with her vigor might just turn out to be the next Anthony Robbins or Robert Kiyosaki!

Owned by the Web

Seems like second joint on the fourth finger on my right hand is starting to ache lately. Perhaps i have been spending too long a time with my fingers on the keyboard of late.

Funny seems like I have been using more keyboard than the pen recently, considering the fact that majority of my time is spent on the web and in front of the computer more than anything else.

Ten years ago when the internet first came into Singapore. Life was so different. And then all of a sudden before you know it. Boom! We have all been taken over by the web. The internet and computer is like a black swan. Who would have known we would be living our lives the way we are living today back ten years ago.

One can never really predict the future accurately that is a fact.