03.13
Codeigniter doesn’t offer a way of hiding index.php from URLs out of the box, so we have to use some htaccess magic to make them look pretty.
There are loads of variants around, but I find this one the best:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
With this one, you only need to add your base url to the RewriteBase line and you’re good to go. No need to add exclusions for other directories that aren’t within the CI application folder (i.e – images, scripts). It just works.
I’m using this on around ten projects at the moment and haven’t had any problems with it. If you do find a reason not to use this, or know one that’s even better, please let me know in the comments!
Aaron

No Comment.
Add Your Comment