Welcome Guest, Not a member yet? Register   Sign In
why dont codeigniter just hide index.php by default?
#1

[eluser]runrun[/eluser]
Many users many time wanted to hide that index.php segment. Why not make codeigniter without that by default for the sake of simplicity.
#2

[eluser]avramovic[/eluser]
Probably since not everybody have mod_rewrite support enabled by default. However, I have made simple modification that uses another server extension, mod_env, to set environment variable if mod_rewrite is enabled and then config/config.php automatically hides index.php if that environment variable is set.

.htaccess
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|application|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

<IfModule mod_env.c>
SetEnv SEO_URLS 1
</IfModule>
</IfModule>

And in config.php
Code:
if (isset($_SERVER['SEO_URLS']))
$config['index_page'] = '';
else
$config['index_page'] = 'index.php';

Now besides mod_rewrite it requires mod_env also, however if mod_env is not available you can manually hide index.php, but so far on all servers I've tested this, if mod_rewrite AND mod_env were present, it worked flawlessly!
#3

[eluser]Harold Villacorte[/eluser]
There are plenty of servers that do not support .htaccess as well.
#4

[eluser]CroNiX[/eluser]
CI works out of the box, as is. You throw specific server configs in there and it won't. Then we'd be spending all of our time answering the opposite question.




Theme © iAndrew 2016 - Forum software by © MyBB