0

So here's the thing, i've done the tutorial thing on CI, i have already done some modification in .htaccess to remove index.php in URL, in these case, when viewing records index.php doesn't appear, but when i try to create a new record, index.php suddenly appeared, i'm confused as to why it appeared, i've already done something to .htaccess like so,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]  

Here are some screenies,

Viewing a record: enter image description here

Creating a new record: enter image description here

After Creation: enter image description here

Im confused as to why index.php suddenly appeared, i've already did some changes on .htaccess. am i missing something? please do share your inputs

EDIT I just followed what they ask me to do on their user guide.

Create a news item

<?php echo validation_errors(); ?>

<?php echo form_open('sample_controller/sample_create') ?>

    <label for="title">Title</label> 
    <input type="input" name="title" /><br />

    <label for="text">Text</label>  <textarea name="text"></textarea><br/>
    <input type="submit" name="submit" value="Create news item" /> 

</form>
1
  • can you show us how you generated the link or redirect to that last scenario Commented Feb 16, 2013 at 11:46

4 Answers 4

1

change sample_controller/sample_create to /sample_controller/sample_create

update:

or @cballou answer updating the config will avoid the problem in the first place.

(in config/config.php set $config['index_page'] = '')

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

4 Comments

yes yes this works, but what happen?, i still don't get why it appeared?
with htacces you told appache to route all requests to the index.php file but CI doesn't know about that so its trying to fix your urls... when you set the index_page to empty u r basically telling CI that there is no need for that
ohhh okie understood, though i really don't know anything about mod_rewrite but yeah i get what you mean.
in that case just the first couple of paragraphs here httpd.apache.org/docs/current/mod/mod_rewrite.html should be doing wonders :)
0

try RewriteRule ^(.*)$ index.php?/$1 [PT,L] in place of

RewriteRule .* index.php/$0 [PT,L]

Comments

0

I think the form action attribute contains the index.php segment. Htaccess isn't enough, edit your CodeIgniter configuration files too to remove.

1 Comment

yes i see it, there is this index.php on the action attribute, how do i configure this on my CI, it says here, in urls under user guide and also what @cballou said, that you should edit config.php but they didn't specify how
0

CodeIgniter also requires you to also make adjustments to your config/config.php file to remove the default URL suffix of index.php. It's not highly mentioned in their guides as a necessity when discussing .htaccess.

See documentation here.

3 Comments

i don't get what you mean, is index.php considered a URL suffix or what?
scratch that last comment, i got what you mean, but their documentation didn't say anything on what to change in config.php
Yes to the first question. The vanilla install of CodeIgniter assumes you aren't using .htaccess and therefore defaults to index.php as the index page (URL suffix).

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.