Removing index.php in Expression Engine

With using Expression Engine your pages default to using a index.php on all of your pages which is quite annoying. So rather than being able to tell people to visit your contact page by going to yoursite.com/contact you have to send them to yoursite.com/index.php/contact. Honestly, it’s not a huge deal breaker; however, it’s ideal to not have the index.php on every page. I tried a couple ways to eliminate the index.php. The first way was by using a plugin for Expression Engine that is supposed to write the necessary information on your .htaccess file. However, when I went to use the plugin it basically took my site offline. So I had to just delete the .htaccess file. I’m sure that the plugin does work but maybe something with my hosting wasn’t connecting properly. After trying that a few times I pretty much gave up.

One day I was just browsing around the internet and found a possible solution which did the trick perfectly! With my hosting I am able to access my .htaccess file and write to it. I simply dropped the following code which I got from Wil Linnsen’s website into my .htaccess file.

# BEGIN Expression Engine Rewrite

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?$1 [L]

# END Expression Engine Rewrite

It worked! However all of the links on my website were still automatically including the index.php in the links. To fix that you simply need to remove the index.php option in the backend of Expression Engine under Admin » System Preferences » General Configuration where it says Name of your sites index page. That’s it! Thanks Wil!

Stay In The Loop

Social Gathering

Join our newsletter to get notified about the happenings here at J Taylor Design.