Welcome Guest, Not a member yet? Register   Sign In
I can't remove index.php from my url's (rediect())

hi all,

I have been using Ci for a while now and my client would like the index.php removed.

From the very start, i used the .htaccess sample code provided by the documentation, but it still shows index.php in my url's when using redirect.

Can anyone suggest a reason why or even a solution?



[eluser]Randy Casburn[/eluser]
Is your server IIS by any chance?

Nope, apache Sad

[eluser]Randy Casburn[/eluser]
OK. this is really very, very simple then. But the more information you provide the more help you're like to get. But I'll pull teeth for now I guess..Undecided

Is this a hosted server? Is mod_rewrite extension loaded on the server? Can you provide you .htaccess contents?

Apache Version: 1.3.37

.htaccess content:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt|favicon\.ico|backup|shop|cstemplates|cschat|ads|as|cs\-admin|bugtracker)
RewriteRule ^(.*)$ /index.php/$1 [L]

The RewriteCond works fine except the index.php situ.

phpinfo informs me that mod_rewrite is one of the loaded modules.

[eluser]Randy Casburn[/eluser]
My I have the URL please?

[eluser]Randy Casburn[/eluser]
Your .htaccess looks ok. Just to confirm, your .htaccess works perfectly well in a couple different test environments I have running. Meaning:
1. existing CI installs on test server
2. previously running with .htaccess RewriteCond to elimiate index.php already in place
3. replaced existing .htaccess with your .htaccess provided above

Test passes. I am running Apache 2.2.6 though.

Check your http.conf file to ensure your .htaccess overrides are not limiting something so specifically that mod_rewrite cannot implement a rule set for some reason. Have seen this happen in the past. Look in http.conf for an AllowOverride setting concerning .htaccess.


This may be a stupid question, but have you set the index_page setting to an empty string in config.php ?

[eluser]Randy Casburn[/eluser]
I didn't ask that because looking at the libraries/Config.php site_url() method, the setting will have little relevance unless you have really, really renamed your index.php file to something else. In that case, your .htaccess file will still thwart your efforts here anyway.

if you need proof of this, please set up a little test bed and test it. you will see this setting has no effect.

[eluser]Randy Casburn[/eluser]
Quote:If you are using mod_rewrite to remove the page set this variable so that it is blank.

This really should read "If you are using mod_rewrite to remove 'index.php', this setting will be ignored".

My 2c.


Theme © iAndrew 2016 - Forum software by © MyBB