February 24, 2008 at 9:45 am
· Filed under Apache, PHP, Regex ·Tagged Apache, PHP, Rewrite Rules, RewriteBase
Five days ago my friend gave me a problem. Problem is bellow
His client gave him a job that fixing the broken link of the site.
That site use rewrite engine to rewrite the .html file to .php file. Also the server uses the virtual hosts.
We saw that the rewrite rules are correctly written and the expected files are present. But the link showed that internal server error and it didn’t find the file.
We have noticed that the server find the files in a directory. So we made a script to find the directory of that script, we have noticed that it is not the same directory. But we didn’t find any problem with the rewrite rules. here is the content of the .htaccess file
# enable mod_rewrite
RewriteEngine on
# correct urls for yahoo bot
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
# mod_rewrite rules for ROOT category
RewriteRule ^index([0-9]+).html$ index.php?category=0&page=$1 [QSA,L]
# mod_rewrite rules for categories pages with HTML path option disable
RewriteRule ^(.*)/$ index.php?category=$1 [QSA,L]
RewriteRule ^(.*)/index([0-9]+).html$ index.php?category=$1&page=$2 [QSA,L]
# mod_rewrite rule for suggest listing page
RewriteRule report-listing.php$ report-listing.php [QSA,L]
RewriteRule ^([a-z]+)-listings.html$ listings.php?view=$1 [QSA,L]
RewriteRule ^([a-z]+)-listings([0-9]+).html$ listings.php?view=$1&page=$2 [QSA,L]
# mod_rewrite rules for view listing page
RewriteRule ^([^/]+)-l([0-9]+).html$ view-listing.php?cat=&title=$1&id=$2 [QSA,L]
RewriteRule ^(.*)/([^/]+)-l([0-9]+).html$ view-listing.php?cat=$1&title=$2&id=$3 [QSA,L]
# mod_rewrite rules for additional pages
RewriteRule ^p(.*).html$ page.php?name=$1 [QSA,L]
# mod_rewrite rules for error pages
RewriteRule ^([0-9]+).htm$ error.php?error=$1 [QSA,L]
# mod_rewrite rules for suggest category page
RewriteRule ^suggest-category-([0-9]+).html$ suggest-category.php?id=$1 [QSA,L]
RewriteRule ^LICENSE.htm$ LICENSE.htm [QSA,L]
# mod_rewrite rules for categories pages
RewriteRule ^(.*)_([0-9]+).html$ index.php?category=$1&page=$2 [QSA,L]
RewriteRule ^(.*).html?(.*)$ index.php?category=$1&$2 [QSA,L]
RewriteRule ^(.*).html$ index.php?category=$1 [QSA,L]
ErrorDocument 500 500.htm
ErrorDocument 404 404.htm
ErrorDocument 403 403.htm
ErrorDocument 401 401.htm
After that we made some .html file and put thats in the server and delete the .htaccess file to check that without rewrite rules it works or not. That works!!! So we became confirm that the problem is in rewrite rule.
But the rewrite rules is correct. So where is the problem??????
After googling we have found something about RewriteBase here.
Few days ago i have studied about the virtual hosts of apache, there i have found that the RewriteBase is can be configured for every virtual host. So that I think maybe we found the solution.
Then I have added just one line after the followings
# enable mod_rewrite
RewriteEngine on
#this line is addedd
RewriteBase /
And the things work like a magic.
Have you got this problem before??? If so then what is your experience???
Permalink
February 20, 2008 at 5:46 pm
· Filed under Apache, ubuntu ·Tagged Apache, Linux, ubuntu, Virtual Host
Some days ago I have posted how to configure apache virtual host in windows. You can find it here. Now I will describe how to configure virtual host in Linux. It’s all most same. This will take few steps
1. Locating the config file:
You first work is to find the config file.
- In most setups, apache takes up residence in /usr/local/apache. If so, chances are your configuration file is /usr/local/apache/conf/httpd.conf. I am using Ubuntu (Gutsy Gibbon) and I have found it here.
- If not then let us find it.
$ find / -type f -name httpd
./usr/local/apache/bin/httpd
2 . Now configure the httpd.conf
The virtual host config starts with, the virtual host tag. Anything between the opening (<VirtualHost *>) and the closing (</VirtualHost>) tags is the configuration.
I am going to setup the test.local .
# The localhost in the VirtualHost tag, tells apache that any request with test.local from localhost
NameVirtualHost localhost
<VirtualHost localhost>
# This should be self-explanatory, the name and port under which the server
# identifies itself. If the port is 80 (default) it is not necessary to include it.
# If this is not set to a valid DNS name, server-side redirects will fail.
ServerName test.local
#
ServerAdmin admin@test.local
# Place where the documents for this domain live. replace it by your own
DocumentRoot /var/www/test
</VirtualHost>
This is the basic setup.
3. Last change
Obviously, if you typed http://test.local in your browser, it would not be found by your Internet provider’s DNS server. We’re next going to edit another file to work around that. The second file you need to edit is called hosts, with no file extension. It will enable you to enter specific addresses for specific domains instead of using a DNS lookup. The normal location for this file is:
/etc/hosts
Just go to the bottom of the file, below all the comments and any existing entries and add the following two lines:
127.0.0.1 test.local
That’s all you need to do there. Save and close the hosts file.
Lastly :
You’re almost done! The only remaining thing you need to do is to re-start the Apache server. You need to do this because Apache only reads the configuration file when it first starts up.
Can you browse http://test.local???
Permalink
February 13, 2008 at 3:38 pm
· Filed under Linux ·Tagged Flash, Install, Linux, ubuntu
Here i will describe how to install .tar.gz.
First download the .tar.gz file. Go to http://www.adobe.com and click on the Get Adobe Flash Player button. Make sure you use a browser from your Linux desktop; if you use a Windows browser you will be redirected to the Windows version of the Flash Player 9. Provided you use a Linux browser, you will be redirected to the download page of the Linux version of the Flash Player 9. On the download page you will get a Flash Player .tar.gz file and download it to your computer (in my case I downloaded it to /home/tapos/Desktop).
Now open a terminal then go to the directory like this:
cd /home/tapos/Desktop ##replace this as your download directory
Then ..
tar xvfz install_flash_player_9_linux.tar.gz
cd install_flash_player_9_linux/
sudo ./flashplayer-installer
then the process is bellow.
You will be asked few questions. Just answer this. The red one’s is the answer. You may face one problem with installation directory of the Browser. Please check your usr/lib directory to get the correct installation path.
Copyright(C) 2002-2006 Adobe Macromedia Software LLC. All rights reserved.
Adobe Flash Player 9 for Linux
Adobe Flash Player 9 will be installed on this machine.
You are running the Adobe Flash Player installer as the “root” user.
Adobe Flash Player 9 will be installed system-wide.
Support is available at http://www.adobe.com/support/flashplayer/
To install Adobe Flash Player 9 now, press ENTER.
To cancel the installation at any time, press Control-C. <– <ENTER>
NOTE: Please exit any browsers you may have running.
Press ENTER to continue… <– <ENTER>
Please enter the installation path of the Firefox, Netscape,
or Opera browser (i.e., /usr/lib/mozilla): <– /usr/lib/firefox
dir= /usr/lib/firefox
WARNING: An older version of the Adobe Flash Player has been detected in
/usr/lib/firefox/plugins.
The installer will overwrite this existing binary.
———– Install Action Summary ———–
Adobe Flash Player 9 will be installed in the following directory:
Browser installation directory = /usr/lib/firefox
Proceed with the installation? (y/n/q): <– y
Installation complete.
Perform another installation? (y/n): <– n
Please log out of this session and log in for the changes to take effect.
The Adobe Flash Player installation is complete.
Now check your installed plugins in firefox. Just open firefox and type about:plugins and check it. I have following view.

What is your experience??
Permalink
February 11, 2008 at 7:47 pm
· Filed under Me ·Tagged bangla, Me
অাজ প্রথম বাংলায় লিখলাম। মজা লাগতেছে।
অাপনার অনুভূতি কি?
Permalink
February 1, 2008 at 5:09 pm
· Filed under CODEIGNITER, PHP ·Tagged CODEIGNITER, MVC, PHP, php framework
Access control list (ACL) is a security model. ACL is a way to manage application permissions in a fine-grained, yet easily maintainable and manageable way.
The authentication module of Cake PHP framework has implemented it nicely. Also Zend framework also implemented it. Also in Sourceforge, a project named php generic access control list is available.
My current project uses codeigniter framework. We have faced several problem for authentication system. So that we have decided to implement the ACL to control the authentication system for a controller and a specific function with in the controller.
To implement this we have a configuration file, acl_settings.php in the application/config folder and we make an array for the permission list.
When a controller is going to load, the application call the acl model (acl_model.php) to check the permission. If access available then it allow to make the object of that controller.
Thanks a lot to read this boring post, also i can’t explain it quitely.
Permalink
January 25, 2008 at 5:44 pm
· Filed under PHP ·Tagged PHP, PHP5
$this is a special variable of an object. Using $this, a member variable or methods of the class can be accessed from anywhere inside of that class.
self is a reserve class name which is also used inside the object itself.
For the static members and static methods and constants, self class name is used instead of $this. So when you use static method or variables and call it inside the same class you must use the self not the $this.
Permalink
January 23, 2008 at 4:36 pm
· Filed under PHP ·Tagged CMS, Joomla, PHP, PHP framwwork
It’s a big day for hundreds of thousands of web sites built on top of the popular open-source Joomla! CMS. After over two years of development and reworking, Joomla! 1.5 (stable) has released to the user community today, combining a brand new object-oriented PHP framework with the content management system’s ease of use and its multitude of functional extensions. You can download it from here
Permalink
January 22, 2008 at 4:27 pm
· Filed under Design Pattern, PHP ·Tagged Design Pattern, PHP, Singleton
Singleton design pattern is used to control the instantiation of a class to an Object. The singleton pattern is implemented by creating the class with a method that creates an instance if one does not exists and the constructor of the class is private.
We can implement this in PHP-5 as followings
<?php
class Singleton {
// object instance
private static $instance;
//constructor
private function __construct() {}
//clone
private function __clone() {}
//make instance
public static function getInstance() {
if (self::$instance === null) {//checking the previous instance
self::$instance = new self;
}
return self::$instance;
}
//the other methods of this class
public function doAction() {
…
}
}
?>
<?php
//usage
Singleton::getInstance()->doAction();
?>
In this example we can see that a static variable $instance is declared to hold the instance of the class. Also the constructor and clone method is private, this ensure the controlling of making the new object of that class.
After that we make a public function getInstance to make an instance of the class. This function return a new instance if no instance of the class is not exists, if exists this return that instance.
AND the uses is simple just use $class_name->getInstance() to make a new instance of the class.
Thanks
Permalink
January 22, 2008 at 8:12 am
· Filed under PHP ·Tagged PHP, PHP5
Suppose you want to check a variable is available or not. Then we can use the following
1. using isset:
if(!isset($var)){
//do something
} else{
//do something
}
2. Using empty:
if(!empty($var)){
//do something
} else{
//do something
}
3. Using the Implicit casting facility
if($var){
//do something
} else{
//do something
}
Now explanation and others
1. the isset function just check only if the variables is set(defined/declared) or not. If defined then return true else return flase. But this don’t check that the variable has a value or empty. So you should be careful to use this function. example:
isset($var);// this will return false
—————-
$var = ‘test’;
isset($var);//this will return true
———-
$var = ”;
isset($var) //this will also return true
2. if u use empty then
Returns FALSE if $var has a non-empty and non-zero value.
The following things are considered to be empty:
| “” (an empty string) |
| 0 (0 as an integer) |
| “0″ (0 as a string) |
and this is an opposite of (boolean)$var.
3. Casting of the variable
if you use the casting then it will work as empty method but warning is generated when the variable is not set.
****As of PHP 5, objects with no properties are no longer considered empty
Permalink
January 21, 2008 at 8:21 pm
· Filed under PHP ·Tagged PHP
Ist Thing:
PHP was written by the Danish/Greenlandic programmer Rasmus Lerdorf in 1994 to maintain his personal homepage and named it as Personal Home Page Tools. After Lerdorf combined it with his own Form Interpreter to create PHP/FI (this release is considered PHP version 2).
Zeev Suraski and Andi Gutmans, two Israeli developers at the Technion IIT, rewrote the parser in 1997 and formed the base of PHP 3, changing the language’s name to the recursive initialism PHP: Hypertext Preprocessor. The development team officially released PHP/FI 2 in November 1997 after months of beta testing. Public testing of PHP 3 began and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite of PHP’s core, producing the Zend Engine in 1999. They also founded Zend Technologies in Ramat Gan, Israel, which actively manages the development of PHP.
The Histories of PHP:
| Version |
Release date |
Most important changes |
| PHP 1.0 |
June 8, 1995 |
Officially called “Personal Home Page Tools (PHP Tools)”. This is the first use of the name “PHP”. |
| PHP Version 2 (PHP/FI) |
April 16, 1996 |
Considered by its creator as the “fastest and simplest tool” for creating dynamic web pages . |
| PHP 3.0 |
Jun 6, 1998 |
Development moves from one person to multiple developers. Zeev Suraski and Andi Gutmans rewrite the base for this version. |
| PHP 4.0.0 |
May 22, 2000 |
Added more advanced two-stage parse/execute tag-parsing system called the Zend engine. |
| PHP 4.1.0 |
Dec 10, 2001 |
Introduced the superglobals ($_GET, $_POST, $_SESSION, etc.) |
| PHP 4.2.0 |
April 22, 2002 |
Disabled register_globals by default |
| PHP 4.3.0 |
Dec 27, 2002 |
Introduced the CLI, in addition to the CGI |
| PHP 4.4.0 |
July 11, 2005 |
|
| PHP 5.0.0 |
July 13, 2004 |
Zend Engine II with a new object model. |
| PHP 5.1.0 |
Nov 24, 2005 |
Performance improvements with introduction of compiler (CV) variables in re-engineered PHP Engine. |
| PHP 5.2.0 |
Nov 2, 2006 |
Enabled the filter extension by default |
Please check http://en.wikipedia.org/wiki/Php
Permalink
Older Posts »