Blog about design, web technologies, tutorials...

Removing index.php from URLs for better SEO optimization, htaccess, PHP 5.2.6 and ExpressionEngine

21 May 2008

Posted in: ExpressionEngine Tutorials

Finally my site runs at PHP5, MySql 5. As I announced few months ago, but that happened few days ago. We can feel a little speed up, but besides that, and of course new PHP5 features, there is all like before.

As there is always "but", I experienced some little headache problems. My rewrite rule for removing index.php from URL just stopped working. In that moment I didn’t knew that the update already happened. I was using tutorial from the wiki page of ExpressionEngine

Old rewrite rule:

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

If you had un update of php version to 5.2.6 like me, you can try this solution. This worked for me:

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

NOTE: The blue question mark after index.php. This is working on HostGator servers, maybe for some strange reason, is not working on your site/server.

More about the solution at ExpressionEngine Forum

Update

Just received a very useful comment of Levi Graham. He published one cool extension for EE called LG .htaccess Generator. So, for more .htaccess and ExpressionEngine things, check his page.

Davor Peić is a designer & developer with more then ten years of experience.

About the author

Davor Peić is a designer & developer with more then twelve years of experience. Find more about his work on www.davorpeic.com