Mod Rewrite to remove index.php from url

Discussion in 'Site & Server Administration' started by stephen421, Dec 30, 2012.

  1. #1
    I recently installed a script on one of my sites and am having issues writing a mod_rewrite rule for it. The problem is that every url within the site contains "index.php". For example, http://www.domain.com/index.php/page or even http://www.domain.com/index.php/admin. The directories following index.php don't actually exist so how can I create a more friendly url that doesn't include index.php? I know this has to do with mod_rewrite but I haven't been able to find a specific rule to fix the problem. Does anyone have any suggestions?
     
    stephen421, Dec 30, 2012 IP
  2. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #2
    hi,

    the following .htaccess rule should do the trick:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    Code (markup):
    just make sure you have mod rewrite enabled in your apache.
     
    RoseHosting, Dec 31, 2012 IP