Tuesday, June 4, 2013

Redirect directory to root .htaccess

Simple of the things sometimes waste too much time. Recently I needed this simple htaccess script to direct one of the subdirectory to the root. I needed same url other than the directory part.

This htaccess code did it for me

RewriteEngine On
RewriteBase /
# redirect stores to root
RewriteRule ^stores/(.*)$ /$1 [R=301,NC,L]

This code redirected all the content of the stores directory to root directory.

I placed this code in the root htaccess and removed the htaccess file from stores directory.

Monday, April 15, 2013

Relaod/refresh page with Javascript Jquery

$('#something').click(function() {
location.reload();
});
the reload() function takes an optional parameter that can be set to true to reload from the server rather than the cache. The parameter defaults to false, so by default the page reloads from the browser's cache.

Saturday, April 6, 2013

Installing Ioncube

1. Download ioncube:

wget http://downloads.ioncube.com/loader_down...x86.tar.gz

2. Extract ioncube
tar zxvf ioncube_loaders_lin_x86.tar.gz


3.move file ioncube_loader_lin_5.3.so
mv ioncube/ioncube_loader_lin_5.3.so /usr/lib/php5/20090626/


4.create file called ioncube.ini (I use nano, you pick your editor)
nano /etc/php5/conf.d/ioncube.ini

5.copy and paste this line
zend_extension = /usr/lib/php5/20090626/ioncube_loader_lin_5.3.so

6. Restart Apache
/etc/init.d/apache2 restart


7. check if installed correctly
php –v

You should have working ioncube installation now. If not check what you missed.

Switching to worker mpm from prefork apache 2 on ubuntu


I'm on ubuntu and according to some tutorials, the following lines would do all the tricks:
apt-get install apache2-mpm-worker libapache2-mod-fastcgi php5-fpm php5-gd
a2enmod actions fastcgi alias
Then you setup configuration in /etc/apache2/conf.d/php5-fpm.conf:
<IfModule mod_fastcgi.c>
                AddHandler php5-fcgi .php
                Action php5-fcgi /php5-fcgi
                Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
                FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization</IfModule>
After all these, restart:
service apache2 restart && service php5-fpm restart
 
Done! 

PHP files downloading instead of executing

When you open your site php files are downloading instead of executing follow these simple steps and you will be good to go again.

first, install libapache2-mod-php5

sudo apt-get install libapache2-mod-php5

Then enable it

sudo a2enmod php5

Restart apache

sudo service apache2 restart

Clear your cache on your browser, and re-load the page.

Your php files should start executing again and you will see your site.

Thursday, February 21, 2013

Jquery date picker z-index issue

In your css use

'.ui-datepicker{ z-index: 9999 !important;}'

Here 9999 can be replaced to whatever layer value you want your datepicker available.

Neither any code is to be commented nor adding 'position:relative;' css on input elements. Because increasing the z-index of input elements will have effect on all input type buttons, which may not be needed for some cases.

Thursday, February 14, 2013

Install phpmyadmin

This is how we install phpmyadmin is LAMP stack

apt-get install phpmyadmin

nano /etc/apache2/apache2.conf

and add following code

Include /etc/phpmyadmin/apache.conf

then restart apache

service httpd restart

or

/etc/init.d/apache2 restart

 

access at

localhost/phpmyadmin

or

ip address/phpmyadmin

or

domainname/phpmyadmin

Tuesday, January 1, 2013

Breaking the shell

My biggest weakness has always been my inability to express myself. It happens often that I know much more than the people in front but I say nothing even if he is wrong. People think I know nothing and I think why to waste time arguing. But now I need to break this shell I have built around myself. I need to share more what I have learn.