0

I know that this subject has been seen many times here, but I didn't see any of them solving my issue here...

I have an application that is working with Codeigniter. I try to remove the index.php in the URL, but it seems I'm cursed today.

Here's what I have in my config.php file :

$config['base_url']   = "http://".$_SERVER['SERVER_NAME']."/";
$config['index_page']    = "";
$config['uri_protocol']  = 'AUTO';

And here's my .htacess (such as CI suggests) :

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

With this, I'm unable to remove the index.php in the URL. In fact, it removes it well, but I have a pretty 404 then on the screen.

I checked the phpinfos() to see if the mod_rewrite was rightly activated, and there's no problem on this side.

**EDIT**

I checked my apache logs, and here's what I have :

[Wed Jul 18 12:27:08 2012] [error] [client 127.0.0.1] File does not exist: [PATH]/trunk/user

The real path should be :

[PATH]/trunk/application/controllers/user

I saw that all this stuff is setup in the index.php file, but it seems that it's never called...

Could anyone suggests me something please to solve this ?

Thanks !

4
  • Take a look at my answer on an other similar question: stackoverflow.com/questions/11052294/… Commented Jul 18, 2012 at 11:22
  • What is the request URL you are entering? I'm assuming you're entering something like server.com/controllername/user, right? Commented Jul 18, 2012 at 11:24
  • user is my controller. but yes, i'm calling something like host/user/login Commented Jul 18, 2012 at 11:44
  • @LeventeNagy I already tried this tutorial, but without success. Commented Jul 18, 2012 at 11:46

2 Answers 2

0

Try this one:

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

The first condition makes sure the request isn't for a valid file and the second makes sure it isn't for a valid directory. All requests for files or folders that don't actually exist in the file system are sent through index.php.

Sign up to request clarification or add additional context in comments.

3 Comments

Doesn't work. Still have my 404. But the redirect is OK, it removes well the index.php (such as with the htaccess in my post).
You didn't delete the index.php file did you?
Problem solved. It was in the apache configuration of the Virtualhost. I added Options -Indexes FollowSymLinks MultiViews and it worked !
-1

You can't block access to the index.php page as it is the main page that CI works off of.

2 Comments

He's not trying to block access to it, but to remove it from displaying in the URI.
In fact the real error is my 404. The index.php is removing well from the URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.