-4

OK, what I need should fairly simply (and I've already noticed several other related questions, none of which works for me though).

I'm building a CodeIgniter-based website and I need to be able to access all controller using :

www.mysite.com/some-controller/some-method

instead of

www.mysite.com/index.php/some-controller/some-method

What should my .htaccess contain?

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
  • 2
    And you are really sure that [this question](http://stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2?rq=1) doesn't contain the answer you need? – Till Helge May 06 '13 at 11:05
  • Or [that](http://stackoverflow.com/a/13714280/624466) – eyecatchUp May 06 '13 at 11:08
  • @eyecatchUp After updating the paths in `RewriteCond` (since the CI installation resides in a SUB-folder), the answer in your link **does work**. However, how could I make it so that the `/index.php/something` URLs do not work any more? (I just need their without-index.php counterparts). – Dr.Kameleon May 06 '13 at 11:13
  • Give a try to this link. it might help u [http://stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2] – Sid May 06 '13 at 11:30
  • @Sid syntax [name]( link to name without spaces) – HamZa May 06 '13 at 11:45
  • 1
    -1 for obvious reason.... – itachi May 06 '13 at 11:54
  • Same question was already been asked few times before – Lior Elrom May 06 '13 at 12:30
  • @Dr.Kameleon To force redirects from `/index.php/controller/method` to `/controller/method` take a look at the update on [this post](http://www.geedew.com/2011/04/05/remove-index-php-codeigniter/). For me, it worked well using [this .htaccess](http://pastebin.com/raw.php?i=tqvMkkG0) – eyecatchUp May 06 '13 at 13:29

2 Answers2

3

Try this one Remove

 $config['index_page'] ='index.php';

and replace with

 $config['index_page'] ='';
usii
  • 1,113
  • 1
  • 10
  • 17
1

Please put this to your .htaccess file

  <IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
  </IfModule>
Kalpesh Patel
  • 2,772
  • 2
  • 25
  • 52
  • 1
    Please don't post duplicated answers, but rather link to existing threads (see comments to the question). – eyecatchUp May 06 '13 at 11:10
  • OK...will tak care of that. But this one is the one that I have been using for my various CI based projects. – Kalpesh Patel May 06 '13 at 11:12
  • Hmm... Thanks for the reply. However, weirdly enough it does not work for me. (and I've changed the `RewriteRule` to `the-full-path/to-my-website-subfolder/index.php?/$1` - not sure If that was the right thing to do though....) – Dr.Kameleon May 06 '13 at 11:14