How to hide index.php from the url ?

In my last article we discussed about the “Add tool to reset locked feeds in Drupal 7“. If you would have work with PHP MVC frameworks you can find most of them are receiving all user requests via front access file like index.php. For example in CodeIgniter, Cygnite Framework, Yii using index.php, for Symfony app_dev.php etc. You may be wondering how to remove this index.php file from url to make it more seo friendly. Today let me show  you all how to remove index.php from the url and display more user friendly url to users using .htacces.

Step1: Create a new file named .htaccess in the same folder as your site’s main index.php file.

Step2: Please make  sure that mod_rewrite is on in your server using phpinfo();

Step3: Add the following lines of code in the newly created file-

<IfModule mod_rewrite.c>

            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php/$1 [L]         
            # RewriteRule ^(.*)$ /index.php?/$1 [L]

Step4: Test your site links and url without index.php to ensure it is working correctly without index.php

 Hope this post helps. Keep visiting for more technical posts.

No comments:

Post a Comment

Follow Us On Facebook Open Source Web Developers by Appsntech facebook group Twitter Open Source Web Developers by Appsntech twitter group Google+ Open Source Web Developers by Appsntech Google group Linkedin Open Source Web Developers by Appsntech, LinkedIn group
Copyright @2011-2015 All rights reserved. Powered By- Sanjoy Dey Productions