Thursday, October 23, 2014

Removing index.php From CodeIgniter URL's

In this post we shall discuss how to remove index.php from CodeIgniter ( aka CI) URL's. When ever we have a a fresh copy of CI we find URL's like:

example.com/index.php/news/article/my_article


In order to convert them in to more meaningful and SEO friendly URL's just create a .htaccess file in the CI root and add the following lines to it.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]


The above rules will be applied to all requests either with or without the index.php part. A modified version of the htaccess instructions can be found on CodeIgniter User's Guide, but it does not work for every one (including myself) and the above solution can also be found on CI Forums.

In order to create a .htaccess file in Windows do the following:

  • Just create a new text document and make the desired change and then save it using the Save As option.
  • In the Save As dialog provide the file name as ".htaccess" (within quotes)
  • In the Save as type drop down below the file name field select All Files and save the file
  • You will get your .htaccess file.

Friday, September 26, 2014

Wednesday, October 9, 2013

Selecting First Option of a Drop Down/Combo Box using JQuery

This one is pretty simple and straight forward. I am just placing it here for future reference and may be it will be helpful to people looking for a similar solution.

If you want to select the first option of an HTML drop down/select control/combo box, just use the following:

$("#target").val($("#target option:first").val());

I found the solution on Stack Overflow.

Hope it helps, if it does just drop a comment, it will keep me motivated :)

Tuesday, June 18, 2013

Including/Excluding a Category From Wordpress Search Query

Recently I was working on a Wordpress site where I had to design two types of search. Basically the searches needed to identify a particular post category. I designed two search forms one for general search (searchform.php) and the other for category specific search (searchform-category.php). Further deatils are as follow:

  1. General Search:
    • The General Search was meant to search the entire site except a particular category.
    • This meant that I needed to exclude that particular category.
    • For excluding the category, I simply added the the following hidden field:
        • where 5 denotes the category ID to exclude.
      • In case you want to exclude multiple categories the following should work:
  2. Category Specific Serach (Advanced Search):
    • The advanced search was meant to search in on specific category and was available to only logged in users.
    • This meant that I needed to specifically instruct WP which category to search in.
    • In my advance/category search form I added the following:
        • where 5 denotes the category ID to search in.
      • In case you want to search in multiple categories, the following will work for you
The support forums on Wordpress.org helped me a lot, but there was no clear cut and tested solution available there so I wrote this post for myself and other like me out there :). The above have been tested with Wordpress 3.5.1.

I will be looking at Wordpress Theme Development and Customization in the coming articles, till then:

Happy search customization on Wordpress. :D

Wednesday, July 25, 2012

Enabling LDAP on XAMPP 1.8.0 for Active Directory on Windows XP


Recently I installed XAMPP 1.8.0 on Windows XP. The XAMPP Server was working fine after installation and the control panel has really been given a good, clean and detailed look.

One of my applications needed PHP's LDAP Module so I went into the php.ini file located at [Your Drive]:\xampp\php\php.ini. and simply un-commented the line:

extension=php_ldap.dll

After doing the above I saved the INI file and restarted Apache service from the XAMPP Control Panel only to find the warning:

Warning PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_ldap.dll'
After a bit of Googling I found this solution on the XAMPP Support Forum:


  • Added  [Your Drive]:\xampp\php to the PATH environment variable.
  • Move the file: libsasl.dll, from  [Your Drive]:\xampp\php to  [Your Drive]:\xampp\apache\bin.
  • Restart Apache from XAMPP Control Panel

After this Apache successfully started without any warnings or errors and phpinfo() also reported the LDAP Module as running. Hope it will save your time and effort from searching, browsing and understanding what is written at the link below :)

Source: Use LDAP extension ? [XAMPP Support Forum]

CHEERS :D

Tuesday, May 1, 2012

Resetting an Auto Incremental Primary Key on SQL Server

Almost all of us create tables in SQL Server with auto incremental primary keys. After creating these tables we write programs which use these tables to place data in them. These programs under go a  lot of testing and thus place a lot of test data in these tables and in turn increment the value of such auto increment fields.

Once all the testing is said and done and you are all set to launch your program/application/software you empty the database/tables so that there is no dummy/test data. but the simple delete statement:

DELETE FROM [tableName];

only clears the data but does not reset the values of any auto increment  fields, this gives a sense of uncleanliness when you are delivering the product/project.

So to reset any auto incremental primary key in MS SQL Server 2008 user defined database tables use the following command after the DELETE statement above.

DBCC CHECKIDENT ("dbo.[tableName]", RESEED, 0);

After the command has executed the next value generated for the auto incremental primary key would be 1, hence the count has been reset, giving a sense of a fresh start or a new beginning. Now you can test a fresh or deliver it a fresh. As pizza companies say Oven Hot we developers can say Database Fresh :).

Happy resetting. :)

Sunday, July 25, 2010

Problem: Slow Internet on Windows 7

I recently bought a Dell 1564 and installed Windows 7 Ultimate (64 bit) on it. Before this laptop I had a Dell Latitude 610 with Windows XP Professional (32 bit). Ever since I satrted using Windows 7 I always got a felling that I was experiencing very slow internet browsing speeds. I tried all the major browsers IE 8 (that came with Windows 7), Mozilla Firefox 3.6.3 (both with and without add ons) and of course my personal favorite Google Chrome.

Before Windows 7 (i.e. on Windows XP Professional) on the same Internet Connection (a Mobilink Infinity Wifi Broadband Connection) I was having a great Internet surfing and downloading experience. So finally after some 2 months of suffering, I finally decided to see if I was the only one suffering from the same issue and thus decided to do a Google Search and found out that I was not the only one with the help of Google Suggest, so instead of writing my own search query I decided to go with Google Suggest and searched for "slow internet windows 7".

So the first article that came up in search at that time was Microsoft's own explanation in the form of an article titled "Why is my Internet connection so slow?", after skimming through the article I found that this was of no use to a tech user as he would have already checked and made all the suggestions provided in the article. Then I found two really helpful articles on "Microsoft Social" which were "Painfully slow internet on Windows 7" and "Slow Internet and Page Timeouts". Although the second article was intended for Windows Vista, but works for Windows 7 as well. Here I will summarize only the key points from the two and will try to make them equally useful for both teach and general user. Please be advised not to make any changes to the Windows Registry without proper backup or supervision and better to try out all the other suggestions leaving registry as the absolute last resort.

Use Selective Startup (Clean Boot)
  • Click Start, click Control Panel, click Administrative Tools, and then double-click System Configuration.
  • Click Continue, or provide Administrator credentials if prompted.
  • Click the General tab, and click Selective startup.
  • Under Selective startup uncheck Load startup items.
  • Click the Services tab, check the Hide all Microsoft services box, and then click Disable all (not necessary to disable all services but a few that take up internet or network resources. On Dell its found that "Advanced Networking Service" by Dell is found to cause the problem).
  • Click the Apply, then OK, and then Restart.


Use Fix it For Me or Fix it Yourself
  • For all the Help please go here.

Disable IP v6

Try uninstalling IPv6 on all interfaces, removing any IPv6 virtual adapters, and resetting the TCP/IP stack. To remove IPv6, go into the properties for each network adapter and either uncheck the box next to the protocol "Internet Protocol version 6 (TCP/IPv6), that will disable it, or select it and click uninstall, which will remove it off the computer. Then go into device manager and remove any 4to6 adapters, WUN miniport adapters, or tunnel adapters.

NOTE: You should do this for each network connection.