Hi All,
we have built web site in PHP, Mysql Database and Apache web server. Site is running fine on localhost(Window) but when we try to deploy it on our test environment (ubuntu 12.04.2 platform) .htaccess is not working. I am not getting any error like 500 Internal server error or any thing, index page is loading but after that none of the pages are loading.
I have enabled mod_rewrite on apache also changed AllowOverride All in /etc/apache2/sites-available/default, still its not working.
Same files when i deploy on Linux shared hosting is working fine. How can we solve this. kindly share your inputs.
Below are the functions which are used in router class
public function loader()
{
/*** check the route ***/
$this->getController();
/*** if the file is not there diaf ***/
if (is_readable($this->file) == false)
{
$this->file = $this->path.'/error404.php';
$this->controller = 'error404';
}
/*** include the controller ***/
require $this->file;
/*** a new controller class instance ***/
$class = $this->controller . 'Controller';
$controller = new $class($this->registry);
/*** check if the action is callable ***/
if (is_callable(array($controller, $this->action)) == false)
{
$action = 'index';
}
else
{
$action = $this->action;
}
/*** run the action ***/
$controller->$action();
}
/**
*
* @get the controller
*
* @access private
*
* @return void
*
*/
private function getController() {
/*** get the route from the url ***/
$route = (empty($_GET['rt'])) ? '' : $_GET['rt'];
if (empty($route))
{
$route = 'index';
}
else
{
/*** get the parts of the route ***/
$parts = explode('/', $route);
$this->controller = $parts[0];
if(isset($parts[1]))
{
echo $this->action = $parts[1];
}
}
if (empty($this->controller))
{
$this->controller = 'index';
}
/*** Get action ***/
if (empty($this->action))
{
$this->action = 'index';
}
/*** set the file path ***/
$this->file = $this->path .'/'. $this->controller . 'Controller.php';
}
below is the .htaccess file
RewriteBase /var/www/pepnew/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
Below is the default file on /etc/apache2/sites-available
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>