Make Your URL Smart (Part -1)

When we have started any project with any framework then its look odd to see the index.php at URL all time.
So its better to remove the index.php from URL and make URL smart.
I am showing the process to remove index.php for Linux base OS system and for KOHANA frmawork. The procedure for other framework are also same. So you can remove index.php for other framework in same way.

There are FOUR steps to remove index.php from URL.
1. Edit your bootstrap file [bootstrap.php]

  • Change the base URL to located the actual directory to your file system
  • Make its empty string to index_file

Its looks ilke the bellow:

	Kohana::init(array(
	'base_url'   => '/restapi/',  // Your base Url
        'index_file' => '',
	));

2. Then Edit the .htaccess file

	RewriteBase /YOUR_PROJECT_DIRECTORY_AT_YOUR_FILE_SYSTEM/	//Same as bootstrap

3. Run command in shell to enable the write.

	sudo a2enmod  rewrite
	sudo nano /etc/apache2/sites-enabled/000-default

Edit the 000-default file and save

		Allowoverride all

4. Then restart your server

sudo /etc/init.d/apache2 restart

We have done. Now enjoy your smart URL.
In my next post on this category i will try to cover the routing process. Enjoy!!!!

Advertisements