Tuesday, August 30, 2011

CodeIgniter – No input file specified error – .htaccess – PHP5 – Apache 2

simply i used following .htaccess code


RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]


difference of below code and codeigniter documentation code is "?" of third row. i highlighted it.


How to setup virtual host in ubuntu

Step 1: setup a virtual domain
open /etc/hosts and add a virtual domain with a specific local IP. In this file it contains ip and domain name separated by a space. You can also add the port using a colon with the IP. Lets assume that our virtual domain name is “domain.local” – and It will listen to the ip “127.0.0.1″

so we will add the following line to our /etc/hosts file
127.0.0.1 domain.local

now whenever you point to http://domain.local – your browser will actually open http://127.0.0.1

Step 2: configure virtual host with apache

here we will configure our newly added virtual domain against apache as a virtual host, and did I forget to say, with mod_rewrite enabled :)
goto /etc/apache2/sites-available and create a file named “domain.local” – I recommend to keep it the same name as your virtual domain.
sudo gedit /etc/apache2/sites-available/domain.local
write the following contents inside. but please note to create the appropriate directory before linking your virtual host with that, for example we’ve create a folder named “/var/www/domain” and linked that directory as my document root in the following configuration file.

<VirtualHost *:80>
ServerName domain.local
DocumentRoot " /var/www/domain"
DirectoryIndex index.html index.php

<Directory " /var/www/domain">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

now create a symbolic link of this file to /etc/apache2/sites-enabled directory as “domain.local”
sudo ln -s /etc/apache2/sites-available/domain.local /etc/apache2/sites-enabled/domain.local

Step 3: restart apache (or reload)
simple, either one of the followings
sudo /etc/init.d/apache2 restart
or
sudo /etc/init.d/apache2 reload
and you are done! now you can point your browser to http://domain.local