Take the index.php out of Code Igniter URLs
I'm very new to Code Igniter (as in I just finished their "official" video tutorial), and I was wondering if there was a way to clean up the URLs just a little bit more.
Basically, is there some setting to keep the "index.php" out of t开发者_如何学编程he URL?
So instead of this...
http://localhost/codeigniter/index.php/blog/comments/
...you see this:
http://localhost/codeigniter/blog/comments/
Or do I have to rewrite the URLs myself with .htaccess?
Using an .htaccess is easier, other ways wouldn't probably work on shared hosting I guess. That would do I guess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Please follow the following instructions.
http://codeigniter.com/wiki/mod_rewrite/
As simple as 1 htaccess file and 1 modification to the config file
You don't "have" to use the htaccess but doing it any other way would be a whole mass of kludge (Think redirecting in php from .../index.php/... to the non index.php version).
Any php dev worth their salt would do it in the .htaccess.
精彩评论