lemoncodes
lemoncodes

Reputation: 2421

Codeigniter's index.php appears after htaccess modification

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>

Upvotes: 0

Views: 110

Answers (4)

Josh
Josh

Reputation: 3284

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'] = '')

Upvotes: 1

Corey Ballou
Corey Ballou

Reputation: 43467

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.

Upvotes: 0

wintercounter
wintercounter

Reputation: 7488

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

Upvotes: 0

Ripa Saha
Ripa Saha

Reputation: 2540

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

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

Upvotes: 0

Related Questions